Skip to content

Commit 793f12f

Browse files
authored
chore(ci): create v2 alpha release workflow (#1719)
1 parent 61ad5ac commit 793f12f

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

Diff for: .github/workflows/make-v2-release.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Make Release v2 (pre-release)
2+
on:
3+
workflow_dispatch: {}
4+
concurrency:
5+
group: on-release-publish
6+
jobs:
7+
run-unit-tests:
8+
uses: ./.github/workflows/reusable-run-linting-check-and-unit-tests.yml
9+
publish-npm:
10+
needs: run-unit-tests
11+
# Needed as recommended by npm docs on publishing with provenance https://docs.npmjs.com/generating-provenance-statements
12+
permissions:
13+
id-token: write
14+
contents: write
15+
runs-on: ubuntu-latest
16+
outputs:
17+
RELEASE_VERSION: ${{ steps.set-release-version.outputs.RELEASE_VERSION }}
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
21+
- name: Setup NodeJS
22+
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
23+
with:
24+
node-version: '18'
25+
cache: 'npm'
26+
- name: Setup auth tokens
27+
run: |
28+
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
29+
- name: Setup dependencies
30+
uses: ./.github/actions/cached-node-modules
31+
- name: Version
32+
run: |
33+
# Version all packages to next major version (2.0.0) without pushing to git, generating changelog or running commit hooks
34+
# Since the version stored in the lerna.json will always be a 1.x.x version, we manually set the version to 2.0.0
35+
npx lerna version major --force-publish --no-push --no-git-tag-version --no-commit-hooks --no-changelog --yes
36+
- name: Set alpha iteration
37+
run: |
38+
# Get the current alpha version from npm i.e 2.0.0-alpha.0 -> 0, 2.0.0-alpha.1 -> 1 (default to -1 if no alpha versions exist = first pre-release)
39+
ITERATION=$(npm show @aws-lambda-powertools/commons time --json | jq -r 'to_entries | map(select(.key | startswith("2.0.0-alpha"))) | sort_by(.key) | last | .key // "-1"')
40+
# Write the new version to the file
41+
echo "{ \"iteration\": $((ITERATION + 1)) }" > v2.json
42+
- name: Increment version in UA
43+
run: |
44+
# Increment the version in the UA
45+
echo "// this file is auto generated, do not modify\nexport const PT_VERSION = '2.0.0-alpha.$(jq -r '.iteration' v2.json)';" > packages/commons/src/version.ts
46+
- name: Build
47+
run: |
48+
npm run build:prod -w packages/batch \
49+
-w packages/commons \
50+
-w packages/idempotency \
51+
-w packages/logger \
52+
-w packages/metrics \
53+
-w packages/parameters \
54+
-w packages/tracer
55+
- name: Pack packages
56+
run: |
57+
npm pack -w packages/batch \
58+
-w packages/commons \
59+
-w packages/idempotency \
60+
-w packages/logger \
61+
-w packages/metrics \
62+
-w packages/parameters \
63+
-w packages/tracer
64+
- name: Publish to npm
65+
run: |
66+
npm publish aws-lambda-powertools-batch-*.tgz --tag next --provenance
67+
npm publish aws-lambda-powertools-commons-*.tgz --tag next --provenance
68+
npm publish aws-lambda-powertools-idempotency-*.tgz --tag next --provenance
69+
npm publish aws-lambda-powertools-logger-*.tgz --tag next --provenance
70+
npm publish aws-lambda-powertools-metrics-*.tgz --tag next --provenance
71+
npm publish aws-lambda-powertools-parameters-*.tgz --tag next --provenance
72+
npm publish aws-lambda-powertools-tracer-*.tgz --tag next --provenance
73+
- name: Set release version
74+
id: set-release-version
75+
run: |
76+
VERSION="2.0.0-alpha.$(cat v2.json | jq .iteration -r)"
77+
echo RELEASE_VERSION="$VERSION" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)