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