Skip to content

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 3 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

### Related issues, RFCs

<!--- Add here the number to the Github Issue or RFC that is related to this PR. -->
<!-- **Issue number:** #123 -->
Copy link
Contributor Author

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.

<!--- Add here the number (i.e. #42) to the Github Issue or RFC that is related to this PR. -->
<!--- If no issue is present the PR might get blocked and not be reviewed. -->
**Issue number:**

### PR status
Expand Down
197 changes: 197 additions & 0 deletions .github/workflows/make-release.yml
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
111 changes: 0 additions & 111 deletions .github/workflows/on-release-prod.yml

This file was deleted.