Skip to content

Commit 650879b

Browse files
committed
ci: add release workflow
1 parent cbac364 commit 650879b

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Build on minimum supported platforms
22

33
on:
4+
workflow_call:
5+
inputs:
6+
identifier:
7+
required: true
8+
type: string
9+
410
pull_request:
511

612
permissions: {}

.github/workflows/release.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
persist-credentials: false
69+
70+
- name: Create new version tag ${{ needs.extract-release-version.outputs.version }}
71+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
72+
with:
73+
script: |
74+
github.rest.git.createRef({
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
ref: `refs/tags/${process.env.RELEASE_VERSION}`,
78+
sha: context.sha,
79+
force: true
80+
})
81+
82+
- name: Create Pull Request
83+
env:
84+
GH_TOKEN: ${{ github.token }}
85+
run: |
86+
gh pr create \
87+
--title "Merge back ${RELEASE_VERSION} release commit to main" \
88+
--body "New version ${RELEASE_VERSION} release commit" \
89+
--head release \
90+
--base main

.github/workflows/unit-test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Unit Test
22

33
on:
4+
workflow_call:
5+
inputs:
6+
identifier:
7+
required: true
8+
type: string
9+
410
pull_request:
511

612
permissions: {}

0 commit comments

Comments
 (0)