Skip to content

Commit 78f904a

Browse files
committed
ci: add release workflow
1 parent f0a3f5c commit 78f904a

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ 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

.github/workflows/integ-test.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Integration 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

.github/workflows/release.yaml

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
integ-test:
48+
name: Integration Tests
49+
needs:
50+
- validate-version-format
51+
uses: ./.github/workflows/integ-test.yaml
52+
with:
53+
identifier: workflow-call-integration-test
54+
55+
build-on-minimum-supported-platforms:
56+
name: Build on minimum supported platforms
57+
needs:
58+
- validate-version-format
59+
uses: ./.github/workflows/build-on-minimum-supported-platform.yaml
60+
with:
61+
identifier: workflow-call-build-on-minimum-platforms
62+
63+
release:
64+
name: Release new version
65+
needs:
66+
- extract-release-version
67+
- unit-test
68+
- integ-test
69+
- build-on-minimum-supported-platforms
70+
runs-on: ubuntu-latest
71+
env:
72+
RELEASE_VERSION: ${{ needs.extract-release-version.outputs.version }}
73+
steps:
74+
- name: Checkout Code
75+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
76+
with:
77+
persist-credentials: false
78+
79+
- name: Create new version tag ${{ needs.extract-release-version.outputs.version }}
80+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
81+
with:
82+
script: |
83+
github.rest.git.createRef({
84+
owner: context.repo.owner,
85+
repo: context.repo.repo,
86+
ref: `refs/tags/${process.env.RELEASE_VERSION}`,
87+
sha: context.sha,
88+
force: true
89+
})
90+
91+
- name: Create Pull Request
92+
env:
93+
GH_TOKEN: ${{ github.token }}
94+
run: |
95+
gh pr create \
96+
--title "Merge back ${RELEASE_VERSION} release commit to main" \
97+
--body "New version ${RELEASE_VERSION} release commit" \
98+
--head release \
99+
--base main

.github/workflows/unit-test.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ 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

0 commit comments

Comments
 (0)