-
Notifications
You must be signed in to change notification settings - Fork 68
128 lines (112 loc) · 3.9 KB
/
Copy pathprod-release.yml
File metadata and controls
128 lines (112 loc) · 3.9 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Release
permissions:
contents: write
id-token: write
on:
workflow_dispatch:
inputs:
version_bump:
required: false
description: '[Optional] Override semantic versioning with explict version (allowed values: "patch", "minor", "major", or explicit version)'
default: ''
dist_tag:
description: 'NPM dist-tag to publish under; delete to publish without an explicit dist-tag'
required: false
default: 'latest'
env:
NODE_OPTIONS: "--max-old-space-size=4096"
jobs:
pre-release-ci:
uses: ./.github/workflows/shared-ci.yml
# Once all tests have passed, run semantic versioning
version:
runs-on: ubuntu-latest
needs: [pre-release-ci]
environment: release
steps:
- name: Require a branch
if: github.ref_type != 'branch'
run: |
echo "::error::Dispatch this workflow from a branch (got ${{ github.ref_type }} '${{ github.ref_name }}'). To release a specific commit, point a branch at it first."
exit 1
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
persist-credentials: false
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci --unsafe-perm
- name: Configure AWS Credentials for Release
uses: aws-actions/configure-aws-credentials@v5
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::587316601012:role/GitHub-CI-CI-Bot-Credential-Access-Role-us-west-2
role-session-name: CI_Bot_Release
# Use AWS Secrets Manager GHA to retrieve CI Bot Creds
- name: Get CI Bot Creds Secret
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: Github/aws-crypto-tools-ci-bot
parse-json-secrets: true
# Log in as the CI Bot
- name: Log in as CI Bot
run: |
echo ${{ env.GITHUB_AWS_CRYPTO_TOOLS_CI_BOT_ESDK_RELEASE_TOKEN }} > token.txt
gh auth login --with-token < token.txt
rm token.txt
gh auth status
gh auth setup-git
- name: Configure git
env:
BRANCH: ${{ github.ref_name }}
run: |
git config --global user.name "aws-crypto-tools-ci-bot"
git config --global user.email "no-reply@noemail.local"
git checkout "$BRANCH"
- name: Version packages
env:
VERSION_BUMP: ${{ github.event.inputs.version_bump }}
run: |
# Generate new version and CHANGELOG entry and push it
npx lerna version --conventional-commits --git-remote origin --yes ${VERSION_BUMP:+$VERSION_BUMP --force-publish}
# Log the commit for posterity
git log -n 1
publish:
runs-on: ubuntu-latest
needs: [pre-release-ci, version]
environment: release
steps:
# Include the version-bump commit the version job pushed
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
- name: Update npm
run: npm install -g npm@latest
- run: npm ci
- run: npm run build --if-present
- name: Publish
env:
NPM_CONFIG_PROVENANCE: true
DIST_TAG: ${{ github.event.inputs.dist_tag }}
run: |
if [ -n "$DIST_TAG" ]; then
npx lerna publish from-package --yes --concurrency 1 --dist-tag "$DIST_TAG"
else
npx lerna publish from-package --yes --concurrency 1
fi
# Once publishing is complete, validate that the published packages are useable
validate:
uses: ./.github/workflows/shared-ci.yml
needs: [publish]
with:
test-published-packages: true