Skip to content

Commit 0f52ad1

Browse files
committed
chore(ci): fix alpha versioning pre-release
1 parent 1f41355 commit 0f52ad1

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

.github/workflows/make-v2-release.yml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Make Release v2 (pre-release)
2+
on:
3+
workflow_dispatch: {}
4+
5+
permissions:
6+
contents: read
7+
8+
concurrency:
9+
group: on-release-publish
10+
jobs:
11+
run-unit-tests:
12+
uses: ./.github/workflows/reusable-run-linting-check-and-unit-tests.yml
13+
publish-npm:
14+
needs: run-unit-tests
15+
# Needed as recommended by npm docs on publishing with provenance https://docs.npmjs.com/generating-provenance-statements
16+
permissions:
17+
id-token: write
18+
environment: Release
19+
runs-on: ubuntu-latest
20+
outputs:
21+
RELEASE_VERSION: ${{ steps.set-release-version.outputs.RELEASE_VERSION }}
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
25+
- name: Setup NodeJS
26+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
27+
with:
28+
node-version: '20'
29+
cache: 'npm'
30+
- name: Setup auth tokens
31+
run: |
32+
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
33+
- name: Setup dependencies
34+
uses: ./.github/actions/cached-node-modules
35+
with:
36+
# We don't build the packages here as we want to version them first
37+
build: false
38+
- name: Version
39+
run: |
40+
# Version all packages to next major version (2.0.0) without pushing to git, generating changelog or running commit hooks
41+
# 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
42+
npx lerna version major --force-publish --no-push --no-git-tag-version --no-commit-hooks --no-changelog --yes
43+
- name: Set alpha iteration
44+
run: |
45+
# 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)
46+
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"' | cut -d '.' -f 4)
47+
# Write the new version to the file
48+
echo "{ \"iteration\": $((ITERATION + 1)) }" > v2.json
49+
- name: Increment version in UA
50+
run: |
51+
# Increment the version in the UA
52+
echo -e "// 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
53+
- name: Build
54+
run: |
55+
npm run build -w packages/commons &
56+
npm run build -w packages/batch \
57+
-w packages/idempotency \
58+
-w packages/logger \
59+
-w packages/metrics \
60+
-w packages/parameters \
61+
-w packages/tracer
62+
- name: Pack packages
63+
run: |
64+
npm pack -w packages/batch \
65+
-w packages/commons \
66+
-w packages/idempotency \
67+
-w packages/logger \
68+
-w packages/metrics \
69+
-w packages/parameters \
70+
-w packages/tracer
71+
- name: Publish to npm
72+
run: |
73+
npm publish aws-lambda-powertools-batch-*.tgz --tag next --provenance
74+
npm publish aws-lambda-powertools-commons-*.tgz --tag next --provenance
75+
npm publish aws-lambda-powertools-idempotency-*.tgz --tag next --provenance
76+
npm publish aws-lambda-powertools-logger-*.tgz --tag next --provenance
77+
npm publish aws-lambda-powertools-metrics-*.tgz --tag next --provenance
78+
npm publish aws-lambda-powertools-parameters-*.tgz --tag next --provenance
79+
npm publish aws-lambda-powertools-tracer-*.tgz --tag next --provenance
80+
- name: Set release version
81+
id: set-release-version
82+
run: |
83+
VERSION="2.0.0-alpha.$(cat v2.json | jq .iteration -r)"
84+
echo RELEASE_VERSION="$VERSION" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)