-
Notifications
You must be signed in to change notification settings - Fork 156
chore(ci): refactor release workflow #2028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3fe9230
Update GitHub Actions workflows
am29d 1fcf2ac
remove env, use git sha
am29d 5ebc175
Update GitHub Actions references to use github.sha
am29d 7030918
change publish from package using sha instead of tag
am29d e092ad5
remove unnecessary token for checkout
am29d b90beb4
add workflow docs and comments
am29d a377220
small wording changes
am29d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
name: Make Release | ||
|
||
# RELEASE PROCESS | ||
# | ||
# === Automated activities === | ||
# 1. [Quality check] run unit tests, linting, examples, layer, doc snippets | ||
# 2. [Release] publish all packages to npmjs.org using the latest git commit, ensure provenance with NPM_CONFIG_PROVENANCE=true | ||
# 3. [Create tag] create a new git tag using released version, i.e. v1.13.1 | ||
# 4. [Publish layer] build and package layer, kick off the workflow for beta and prod deployment, including canary tests | ||
# 5. [Publish layer] update documentation with the latest layer ARN version of the prod deployment | ||
# 6. [Publish layer] create PR to merge the updated documentation | ||
# | ||
# === Manual activities === | ||
# 1. Kick off `make-version` workflow to bump and review the version changes and changelog for each package | ||
# 2. Merge the PR created by `make-version` workflow | ||
# 3. Kick off this workflow to make the release | ||
# 4. Merge the PR created by the `publish_layer` workflow to update the documentation | ||
# 5. Update draft release notes with the latest changes and publish the release on GitHub | ||
|
||
on: | ||
workflow_dispatch: {} | ||
|
||
|
@@ -7,9 +25,15 @@ permissions: | |
|
||
concurrency: | ||
group: on-release-publish | ||
|
||
|
||
jobs: | ||
run-unit-tests: | ||
uses: ./.github/workflows/reusable-run-linting-check-and-unit-tests.yml | ||
# This job publishes the packages to npm. | ||
# It uses the latest git commit sha as the version and ensures provenance with NPM_CONFIG_PROVENANCE flag. | ||
# We don't bump the version because we do that in the `make-version` workflow. | ||
# It also sets the RELEASE_VERSION output to be used by the next job to create a git tag. | ||
publish-npm: | ||
needs: run-unit-tests | ||
# Needed as recommended by npm docs on publishing with provenance https://docs.npmjs.com/generating-provenance-statements | ||
|
@@ -24,35 +48,47 @@ jobs: | |
- name: Checkout code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
# Here `token` is needed to avoid incurring in error GH006 Protected Branch Update Failed, | ||
token: ${{ secrets.GH_PUBLISH_TOKEN }} | ||
# While `fetch-depth` is used to allow the workflow to later commit & push the changes. | ||
fetch-depth: 0 | ||
ref: ${{ github.sha }} | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 | ||
with: | ||
node-version: "20" | ||
cache: "npm" | ||
- name: Setup auth tokens | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git remote set-url origin https://x-access-token:${{ secrets.GH_PUBLISH_TOKEN }}@github.com/$GITHUB_REPOSITORY | ||
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" | ||
- name: Setup dependencies | ||
uses: ./.github/actions/cached-node-modules | ||
- name: Version | ||
run: | | ||
npx lerna version minor --force-publish --no-commit-hooks --yes | ||
- name: Publish to npm | ||
run: | | ||
NPM_CONFIG_PROVENANCE=true npx lerna publish from-git --yes | ||
NPM_CONFIG_PROVENANCE=true npx lerna publish from-package --git-head ${{ github.sha }} --yes | ||
- name: Set release version | ||
id: set-release-version | ||
run: | | ||
VERSION=$(cat lerna.json | jq .version -r) | ||
echo RELEASE_VERSION="$VERSION" >> "$GITHUB_OUTPUT" | ||
|
||
|
||
# This job creates a new git tag using the released version (v1.18.1) | ||
create_tag: | ||
needs: [publish-npm] | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
ref: ${{ github.sha }} | ||
- name: Git client setup | ||
run: | | ||
git config --global user.name 'aws-powertools-bot' | ||
git config --global user.email '[email protected]' | ||
git config remote.origin.url >&- | ||
- name: Create git tag | ||
run : | | ||
git tag -a v${{ needs.publish-npm.outputs.RELEASE_VERSION }} -m "Release v${{ needs.publish-npm.outputs.RELEASE_VERSION }}" | ||
git push origin v${{ needs.publish-npm.outputs.RELEASE_VERSION }} | ||
|
||
# NOTE: Watch out for the depth limit of 4 nested workflow_calls. | ||
# publish_layer -> reusable_deploy_layer_stack -> reusable_update_layer_arn_docs | ||
publish_layer: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ on: | |
required: true | ||
|
||
permissions: | ||
contents: write | ||
contents: read | ||
|
||
env: | ||
BRANCH: main | ||
|
@@ -21,18 +21,15 @@ jobs: | |
concurrency: | ||
group: changelog-build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
id-token: none | ||
steps: | ||
- name: Checkout repository # reusable workflows start clean, so we need to checkout again | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
fetch-depth: 0 | ||
- name: Git client setup and refresh tip | ||
run: | | ||
git config user.name "Release bot[bot]" | ||
git config user.email "[email protected]" | ||
git config pull.rebase true | ||
git config remote.origin.url >&- || git remote add origin https://github.com/"${origin}" # Git Detached mode (release notes) doesn't have origin | ||
git pull origin "${BRANCH}" | ||
ref: ${{ github.sha }} | ||
- name: Download CDK layer artifact | ||
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 | ||
with: | ||
|
@@ -42,11 +39,12 @@ jobs: | |
run: | | ||
ls -la cdk-layer-stack/ | ||
./.github/scripts/update_layer_arn.sh cdk-layer-stack | ||
- name: Update documentation in trunk | ||
run: | | ||
HAS_CHANGE=$(git status --porcelain) | ||
test -z "${HAS_CHANGE}" && echo "Nothing to update" && exit 0 | ||
git add docs/index.md | ||
git commit -m "chore: update layer ARN on documentation" | ||
git pull origin "${BRANCH}" # prevents concurrent branch update failing push | ||
git push origin HEAD:refs/heads/"${BRANCH}" | ||
- name: Create PR | ||
id: create-pr | ||
uses: ./.github/actions/create-pr | ||
with: | ||
files: 'docs/index.md' | ||
temp_branch_prefix: 'ci-layer-docs' | ||
pull_request_title: 'chore(ci): update layer ARN on documentation' | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.