Skip to content

Commit 2b167f8

Browse files
authored
GHA to create release (#437)
<!-- Describe what has changed in this PR --> **What changed?** GHA to create, publish and delete releases. - `create-release`: manually triggered, it validates the input, checks compatibility with sdk-go, and creates draft releases in `api` and `api-go`. - `publish-release`: triggered when a release is published, it publishes the corresponding `api-go` release. - `delete-release`: triggered when a release is deleted, it deletes the corresponding `api-go` release (only works for deleting draft releases). <!-- Tell your future self why have you made these changes --> **Why?** Automation. <!-- Are there any breaking changes on binary or code level? --> **Breaking changes** <!-- If this breaks the Server, please provide the Server PR to merge right after this PR was merged. --> **Server PR**
1 parent 5b6d2a5 commit 2b167f8

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: "Create release"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: "Branch to be tagged"
8+
required: true
9+
default: master
10+
tag:
11+
description: "Tag for new version (v1.23.4)"
12+
required: true
13+
base_tag:
14+
description: "Base tag to generate commit list for release notes"
15+
required: true
16+
skip_sdk_check:
17+
description: "Skip sdk-go compatibility check"
18+
type: boolean
19+
20+
jobs:
21+
prepare-inputs:
22+
name: "Prepare inputs"
23+
runs-on: ubuntu-latest
24+
outputs:
25+
api_commit_sha: ${{ steps.pin_commits.outputs.api_commit_sha }}
26+
api_go_commit_sha: ${{ steps.pin_commits.outputs.api_go_commit_sha }}
27+
steps:
28+
- name: Checkout api
29+
uses: actions/checkout@v4
30+
with:
31+
ref: ${{ github.event.inputs.branch }}
32+
fetch-depth: 0
33+
fetch-tags: true
34+
path: api
35+
36+
- name: Checkout api-go
37+
uses: actions/checkout@v4
38+
with:
39+
repository: temporalio/api-go
40+
ref: ${{ github.event.inputs.branch }}
41+
submodules: true
42+
path: api-go
43+
44+
- name: Validate inputs
45+
env:
46+
BRANCH: ${{ github.event.inputs.branch }}
47+
TAG: ${{ github.event.inputs.tag }}
48+
BASE_TAG: ${{ github.event.inputs.base_tag }}
49+
working-directory: ./api
50+
run: |
51+
if ! [[ "${TAG}" =~ ^v.* ]]; then
52+
echo "::error::Tag is not prefixed with 'v'"
53+
exit 1
54+
fi
55+
56+
if [[ -n "$(git tag -l "$TAG")" ]]; then
57+
echo "::error::Tag already exists"
58+
exit 1
59+
fi
60+
61+
if [[ -z "$BASE_TAG" || -z "$(git tag -l "$BASE_TAG")" ]]; then
62+
echo "::error::Base tag not specified or does not exist"
63+
exit 1
64+
fi
65+
66+
- name: Pin commits sha
67+
id: pin_commits
68+
env:
69+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
BRANCH: ${{ github.event.inputs.branch }}
71+
run: |
72+
API_COMMIT_SHA=$(git -C ./api rev-parse HEAD)
73+
API_GO_COMMIT_SHA=$(git -C ./api-go rev-parse HEAD)
74+
API_GO_API_COMMIT_SHA=$(git -C ./api-go rev-parse HEAD:proto/api)
75+
if [[ "${API_GO_API_COMMIT_SHA}" != "${API_COMMIT_SHA}" ]]; then
76+
echo "::error::api-go ref ${API_GO_COMMIT_SHA} does not reference api ref ${API_COMMIT_SHA}, api-go repo might not be up-to-date."
77+
exit 1
78+
fi
79+
echo "api_commit_sha=$API_COMMIT_SHA" >> "$GITHUB_OUTPUT"
80+
echo "api_go_commit_sha=$API_GO_COMMIT_SHA" >> "$GITHUB_OUTPUT"
81+
82+
check-compatibility-sdk-go:
83+
needs: prepare-inputs
84+
if: ${{ github.event.inputs.skip_sdk_check == false || github.event.inputs.skip_sdk_check == 'false' }}
85+
uses: temporalio/api-go/.github/workflows/check-sdk-compat.yml@master
86+
with:
87+
sdk_ref: latest
88+
api_ref: ${{ needs.prepare-inputs.outputs.api_go_commit_sha }}
89+
90+
create-release:
91+
name: "Create release"
92+
needs: [prepare-inputs, check-compatibility-sdk-go]
93+
if: |
94+
!cancelled() &&
95+
needs.prepare-inputs.result == 'success' &&
96+
contains(fromJSON('["success", "skipped"]'), needs.check-compatibility-sdk-go.result)
97+
runs-on: ubuntu-latest
98+
99+
steps:
100+
- name: Generate token
101+
id: generate_token
102+
uses: actions/create-github-app-token@v1
103+
with:
104+
app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }}
105+
private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }}
106+
owner: ${{ github.repository_owner }}
107+
108+
- name: Checkout
109+
uses: actions/checkout@v4
110+
with:
111+
ref: ${{ needs.prepare-inputs.outputs.api_commit_sha }}
112+
token: ${{ steps.generate_token.outputs.token }}
113+
114+
- name: Create release
115+
env:
116+
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
117+
REF: ${{ needs.prepare-inputs.outputs.api_commit_sha }}
118+
TAG: ${{ github.event.inputs.tag }}
119+
BASE_TAG: ${{ github.event.inputs.base_tag }}
120+
run: |
121+
gh repo set-default ${{ github.repository }}
122+
gh release create "$TAG" --target "$REF" --latest --generate-notes --notes-start-tag "$BASE_TAG" --draft
123+
124+
release-api-go:
125+
needs: [prepare-inputs, create-release]
126+
if: |
127+
!cancelled() &&
128+
needs.create-release.result == 'success'
129+
uses: temporalio/api-go/.github/workflows/create-release.yml@master
130+
with:
131+
ref: ${{ needs.prepare-inputs.outputs.api_go_commit_sha }}
132+
tag: ${{ github.event.inputs.tag }}
133+
api_commit_sha: ${{ needs.prepare-inputs.outputs.api_commit_sha }}
134+
base_tag: ${{ github.event.inputs.base_tag }}
135+
secrets: inherit
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Trigger api-go delete release"
2+
3+
on:
4+
release:
5+
types: [deleted]
6+
7+
jobs:
8+
trigger-api-go-delete-release:
9+
uses: temporalio/api-go/.github/workflows/delete-release.yml@master
10+
with:
11+
tag: ${{ github.event.release.tag_name }}
12+
api_commit_sha: ${{ github.event.release.target_commitish }}
13+
secrets: inherit
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Trigger api-go publish release"
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
trigger-api-go-publish-release:
9+
uses: temporalio/api-go/.github/workflows/publish-release.yml@master
10+
with:
11+
tag: ${{ github.event.release.tag_name }}
12+
api_commit_sha: ${{ github.event.release.target_commitish }}
13+
secrets: inherit

0 commit comments

Comments
 (0)