Skip to content

Commit 65db503

Browse files
committed
ci: use OIDC
1 parent 837cd91 commit 65db503

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

.github/workflows/release.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,38 @@ name: Release
33
on:
44
workflow_dispatch:
55
inputs:
6-
dryRun:
7-
description: 'Do a dry run to preview instead of a real release'
6+
releaseType:
7+
type: choice
8+
description: Release type
89
required: true
9-
default: 'true'
10+
default: dry-run
11+
options:
12+
- release
13+
- dry-run
1014

1115
jobs:
1216
authorize:
1317
name: Authorize
1418
runs-on: ubuntu-latest
1519
steps:
20+
- name: Check branch protection
21+
run: |
22+
if [ "${{ github.event.inputs.releaseType }}" == "dry-run" ]; then
23+
echo "✅ Branch check skipped: dry-run mode allows any branch"
24+
echo "Current branch: ${{ github.ref_name }}"
25+
exit 0
26+
fi
27+
if [ "${{ github.ref_name }}" != "v8.x" ]; then
28+
echo "❌ This workflow can only be triggered from the v8.x branch."
29+
echo "Current branch: ${{ github.ref_name }}"
30+
exit 1
31+
fi
32+
echo "✅ Branch check passed: running from v8.x"
33+
1634
- name: ${{ github.actor }} permission check to do a release
17-
uses: "lannonbr/repo-permission-check-action@2.0.2"
35+
uses: 'lannonbr/repo-permission-check-action@2.0.2'
1836
with:
19-
permission: "write"
37+
permission: 'write'
2038
env:
2139
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2240

@@ -25,17 +43,22 @@ jobs:
2543
runs-on: ubuntu-latest
2644
needs: [authorize]
2745
permissions:
28-
id-token: write
46+
id-token: write # Required for OIDC
2947
contents: write
3048
env:
3149
GIT_AUTHOR_NAME: amplitude-sdk-bot
3250
GIT_AUTHOR_EMAIL: amplitude-sdk-bot@users.noreply.github.com
3351
GIT_COMMITTER_NAME: amplitude-sdk-bot
3452
GIT_COMMITTER_EMAIL: amplitude-sdk-bot@users.noreply.github.com
53+
strategy:
54+
matrix:
55+
node-version: [24.x] # Ensure npm 11.5.1 or later is installed for OIDC
3556

3657
steps:
3758
- name: Checkout
38-
uses: actions/checkout@v1
59+
uses: actions/checkout@v3
60+
with:
61+
fetch-depth: 0
3962

4063
- name: Configure AWS Credentials
4164
uses: aws-actions/configure-aws-credentials@v1
@@ -53,13 +76,14 @@ jobs:
5376
uses: actions/setup-python@v2
5477
with:
5578
python-version: '3.8.x'
79+
5680
- name: Install boto3 for deploy_s3.python
5781
run: pip install boto3==1.14.63
5882

5983
- name: Setup Node.js
6084
uses: actions/setup-node@v3
6185
with:
62-
node-version: 16.x
86+
node-version: ${{ matrix.node-version }}
6387

6488
- name: Install dependencies
6589
run: yarn install --frozen-lockfile
@@ -68,17 +92,15 @@ jobs:
6892
run: make test
6993

7094
- name: Release --dry-run # Uses release.config.js
71-
if: ${{ github.event.inputs.dryRun == 'true'}}
95+
if: ${{ github.event.inputs.releaseType == 'dry-run' }}
7296
env:
7397
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
7598
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
7699
run: npx semantic-release --dry-run
77100

78101
- name: Release # Uses release.config.js
79-
if: ${{ github.event.inputs.dryRun == 'false'}}
102+
if: ${{ github.event.inputs.releaseType == 'release' }}
80103
env:
81104
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
83105
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
84106
run: npx semantic-release

0 commit comments

Comments
 (0)