-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (98 loc) · 3.37 KB
/
release.yaml
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
name: Release
on:
push:
branches:
- release
permissions:
id-token: write
contents: write
jobs:
extract-release-version:
name: Extract release version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-release-version.outputs.result }}
steps:
- name: Extract release version
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: extract-release-version
with:
result-encoding: string
script: |
const matches = `${{ github.event.head_commit.message }}`.match(/[0-9]+\.[0-9]+\.[0-9]+/) ?? []
return matches.length > 0 ? matches[0] : ""
validate-version-format:
name: Validate Version Format
needs:
- extract-release-version
if: ${{ needs.extract-release-version.outputs.version != '' }}
runs-on: ubuntu-latest
steps:
- name: Validated
run: echo "Releasing new version ${{ needs.extract-release-version.outputs.version }}"
unit-test:
name: Unit Tests
needs:
- validate-version-format
uses: ./.github/workflows/unit-test.yaml
with:
identifier: workflow-call-unit-test
build-on-minimum-supported-platforms:
name: Build on minimum supported platforms
needs:
- validate-version-format
uses: ./.github/workflows/build-on-minimum-supported-platform.yaml
with:
identifier: workflow-call-build-on-minimum-platforms
release:
name: Release new version
environment: Release
needs:
- extract-release-version
- unit-test
- build-on-minimum-supported-platforms
runs-on: ubuntu-latest
env:
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
steps:
- name: Checkout Code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: release
fetch-depth: 0
persist-credentials: false
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ format('{0}.release', github.run_id) }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Setup Github Token
id: setup-pat
env:
DEPLOY_SECRET_ARN: ${{ secrets.DEPLOY_SECRET_ARN }}
run: |
PAT=$(aws secretsmanager get-secret-value \
--secret-id "${DEPLOY_SECRET_ARN}" \
| jq -r ".SecretString | fromjson | .Credential")
echo "token=$PAT" >> $GITHUB_OUTPUT
- name: Create new version tag ${{ needs.extract-release-version.outputs.version }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${process.env.RELEASE_VERSION}`,
sha: context.sha,
force: true
})
- name: Sync Back to Main
env:
PAT: ${{ steps.setup-pat.outputs.token }}
GITHUB_USER: aws-amplify-ops
GITHUB_EMAIL: [email protected]
run: |
git config user.name $GITHUB_USER
git config user.email $GITHUB_EMAIL
git push "https://${PAT}@github.com/${{ github.repository }}" HEAD:main