Skip to content

Commit 4c6fd52

Browse files
committed
ci: add release workflow
1 parent f0a3f5c commit 4c6fd52

File tree

3 files changed

+122
-2
lines changed

3 files changed

+122
-2
lines changed

.github/workflows/build-on-minimum-supported-platform.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@ name: Build on minimum supported platforms
22

33
on:
44
workflow_dispatch:
5+
workflow_call:
6+
inputs:
7+
identifier:
8+
required: true
9+
type: string
510
pull_request:
611
branches:
712
- main
813

914
permissions: {}
1015

1116
concurrency:
12-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
17+
group: ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1318
cancel-in-progress: true
1419

1520
jobs:

.github/workflows/release.yaml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- release
7+
8+
permissions:
9+
id-token: write
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
extract-release-version:
15+
name: Extract release version
16+
runs-on: ubuntu-latest
17+
outputs:
18+
version: ${{ steps.extract-release-version.outputs.result }}
19+
steps:
20+
- name: Extract release version
21+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
22+
id: extract-release-version
23+
with:
24+
result-encoding: string
25+
script: |
26+
const matches = `${{ github.event.head_commit.message }}`.match(/[0-9]+\.[0-9]+\.[0-9]+/) ?? []
27+
return matches.length > 0 ? matches[0] : ""
28+
29+
validate-version-format:
30+
name: Validate Version Format
31+
needs:
32+
- extract-release-version
33+
if: ${{ needs.extract-release-version.outputs.version != '' }}
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Validated
37+
run: echo "Releasing new version ${{ needs.extract-release-version.outputs.version }}"
38+
39+
unit-test:
40+
name: Unit Tests
41+
needs:
42+
- validate-version-format
43+
uses: ./.github/workflows/unit-test.yaml
44+
with:
45+
identifier: workflow-call-unit-test
46+
47+
build-on-minimum-supported-platforms:
48+
name: Build on minimum supported platforms
49+
needs:
50+
- validate-version-format
51+
uses: ./.github/workflows/build-on-minimum-supported-platform.yaml
52+
with:
53+
identifier: workflow-call-build-on-minimum-platforms
54+
55+
release:
56+
name: Release new version
57+
needs:
58+
- extract-release-version
59+
- unit-test
60+
- build-on-minimum-supported-platforms
61+
runs-on: ubuntu-latest
62+
env:
63+
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
64+
steps:
65+
- name: Checkout Code
66+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
67+
with:
68+
ref: release
69+
fetch-depth: 0
70+
persist-credentials: false
71+
72+
- name: Configure AWS Credentials
73+
uses: aws-actions/configure-aws-credentials@v4
74+
with:
75+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
76+
role-session-name: ${{ format('{0}.integ-test', github.run_id) }}
77+
aws-region: ${{ secrets.AWS_REGION }}
78+
79+
80+
- name: Setup Github Token
81+
id: setup-pat
82+
env:
83+
SECRET_ARN: ${{ secrets.SECRET_ARN }}
84+
run: |
85+
PAT=$(aws secretsmanager get-secret-value \
86+
--secret-id "${SECRET_ARN}" \
87+
| jq -r ".SecretString")
88+
echo "token=$PAT" >> $GITHUB_OUTPUT
89+
90+
- name: Create new version tag ${{ needs.extract-release-version.outputs.version }}
91+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
92+
with:
93+
script: |
94+
github.rest.git.createRef({
95+
owner: context.repo.owner,
96+
repo: context.repo.repo,
97+
ref: `refs/tags/${process.env.RELEASE_VERSION}`,
98+
sha: context.sha,
99+
force: true
100+
})
101+
102+
- name: Sync Back to Main
103+
env:
104+
PAT: ${{ steps.setup-pat.outputs.token }}
105+
GITHUB_USER: aws-amplify-ops
106+
GITHUB_EMAIL: aws-amplify-ops@amazon.com
107+
run: |
108+
git config user.name $GITHUB_USER
109+
git config user.email $GITHUB_EMAIL
110+
git push "https://${PAT}@github.com/${{ github.repository }}" HEAD:main

.github/workflows/unit-test.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@ name: Unit Test
22

33
on:
44
workflow_dispatch:
5+
workflow_call:
6+
inputs:
7+
identifier:
8+
required: true
9+
type: string
510
pull_request:
611
branches:
712
- main
813

914
permissions: {}
1015

1116
concurrency:
12-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
17+
group: ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1318
cancel-in-progress: true
1419

1520
jobs:

0 commit comments

Comments
 (0)