-
Notifications
You must be signed in to change notification settings - Fork 156
fix(layers): release process + remove duplicate code #1052
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 1 commit
Commits
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
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 |
---|---|---|
@@ -0,0 +1,197 @@ | ||
name: Make Release | ||
on: | ||
workflow_dispatch: {} | ||
concurrency: | ||
group: on-release-publish | ||
jobs: | ||
check-examples: | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_ENV: dev | ||
strategy: | ||
matrix: | ||
example: ["sam", "cdk"] | ||
fail-fast: false | ||
defaults: | ||
run: | ||
working-directory: examples/${{ matrix.example }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: "npm" | ||
- name: Cache node modules | ||
id: cache-node-modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: "./examples/${{ matrix.example }}/node_modules" | ||
# Use the combo between example, name, and SHA-256 hash of all example lock files as cache key. | ||
# It's not possible to use the ${{ matrix.example }} key in the hashFiles fn so | ||
# if any of the lock files (wich should be fairly similar anyway) changes the cache is | ||
# invalidated/discarded for all. | ||
key: ${{ matrix.example }}-cache-examples-node-modules-${{ hashFiles('./examples/*/package-lock.json') }} | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Run tests | ||
run: npm t | ||
check-layer-publisher: | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_ENV: dev | ||
defaults: | ||
run: | ||
working-directory: layer-publisher | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: "npm" | ||
- name: Cache node modules | ||
id: cache-node-modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: "./layer-publisher/node_modules" | ||
# Use the combo between example, name, and SHA-256 hash of the layer-publisher lock files as cache key. | ||
key: cache-layer-publisher-node-modules-${{ hashFiles('./layer-publisher/*/package-lock.json') }} | ||
- name: Install Layer publisher app | ||
run: npm ci | ||
run-unit-tests-on-utils: | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_ENV: dev | ||
strategy: | ||
matrix: | ||
version: [12, 14, 16] | ||
fail-fast: false | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.version }} | ||
cache: "npm" | ||
- name: Setup npm | ||
run: npm i -g npm@next-8 | ||
- name: Cache node modules | ||
id: cache-node-modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: "./node_modules" | ||
# Use the combo between node version, name, and SHA-256 hash of the lock file as cache key so that | ||
# if one of them changes the cache is invalidated/discarded | ||
key: ${{ matrix.version }}-cache-utils-node-modules-${{ hashFiles('./package-lock.json') }} | ||
- name: Install dependencies | ||
# We can skip the install if there was a cache hit | ||
if: steps.cache-node-modules.outputs.cache-hit != 'true' | ||
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts | ||
run: npm ci --foreground-scripts | ||
- name: Build packages | ||
# If there's a cache hit we still need to manually build the packages | ||
# this would otherwise have been done automatically as a part of the | ||
# postinstall npm hook | ||
if: steps.cache-node-modules.outputs.cache-hit == 'true' | ||
run: | | ||
npm run build -w packages/commons | ||
npm run build -w packages/logger & npm run build -w packages/tracer & npm run build -w packages/metrics | ||
- name: Lint | ||
run: npm run lint -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics | ||
- name: Run unit tests | ||
run: npm t -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics | ||
publish-npm: | ||
needs: [check-examples, check-layer-publisher, run-unit-tests-on-utils] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
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 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16" | ||
cache: "npm" | ||
- name: Setup npm | ||
run: | | ||
npm i -g npm@next-8 | ||
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" | ||
- name: Cache node modules | ||
id: cache-node-modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: "./node_modules" | ||
# Use the combo between node version, name, and SHA-256 hash of the lock file as cache key so that | ||
# if one of them changes the cache is invalidated/discarded | ||
key: 16-cache-utils-node-modules-${{ hashFiles('./package-lock.json') }} | ||
- name: Build packages | ||
run: | | ||
npm run build -w packages/commons | ||
npm run build -w packages/logger & npm run build -w packages/tracer & npm run build -w packages/metrics | ||
- name: "Version and publish" | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_PUBLISH_TOKEN }} | ||
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:${GH_TOKEN}@github.com/$GITHUB_REPOSITORY | ||
npx lerna version --conventional-commits --force-publish --yes | ||
npx lerna publish from-git --no-verify-access --yes | ||
publish-docs: | ||
needs: publish-npm | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.8" | ||
- name: Set RELEASE_VERSION env var | ||
run: | | ||
RELEASE_VERSION=$(cat packages/commons/package.json | jq '.version' -r) | ||
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV | ||
- name: Install doc generation dependencies | ||
run: | | ||
pip install --upgrade pip | ||
pip install -r docs/requirements.txt | ||
- name: Setup doc deploy | ||
run: | | ||
git config --global user.name Docs deploy | ||
git config --global user.email [email protected] | ||
- name: Build mkdocs site in "gh-pages" branch and push | ||
run: | | ||
rm -rf site | ||
VERSION="${{ env.RELEASE_VERSION }}" | ||
ALIAS="latest" | ||
echo "Publishing doc for version: $VERSION" | ||
mkdocs build | ||
mike deploy --push --update-aliases --no-redirect "$VERSION" "$ALIAS" | ||
# Set latest version as a default | ||
mike set-default --push latest | ||
- name: Build API docs | ||
run: | | ||
rm -rf api | ||
npm run docs-generateApiDoc | ||
- name: Release API docs to the released version | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./api | ||
keep_files: true | ||
destination_dir: ${{ env.RELEASE_VERSION }}/api | ||
- name: Release API docs to the "latest" version | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./api | ||
keep_files: true | ||
destination_dir: latest/api |
This file was deleted.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was interpreted by the workflow as an actual issue number. The workflow was then trying to assign a label to it but since it doesn't exist it would fail.