-
Notifications
You must be signed in to change notification settings - Fork 88
143 lines (131 loc) · 4.87 KB
/
create-release.yml
File metadata and controls
143 lines (131 loc) · 4.87 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: "Create release"
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to be tagged"
required: true
default: master
tag:
description: "Tag for new version (v1.23.4)"
required: true
base_tag:
description: "Base tag to generate commit list for release notes"
required: true
skip_sdk_check:
description: "Skip sdk-go compatibility check"
type: boolean
dispatch_id:
description: An ID used by external tools to identify workflow runs(can be left empty when running manually)
default: "none"
type: string
jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- name: Dispatch ${{ inputs.dispatch_id }}
run: echo "Dispatch ${{ inputs.dispatch_id }}"
prepare-inputs:
name: "Prepare inputs"
runs-on: ubuntu-latest
outputs:
api_commit_sha: ${{ steps.pin_commits.outputs.api_commit_sha }}
api_go_commit_sha: ${{ steps.pin_commits.outputs.api_go_commit_sha }}
steps:
- name: Checkout api
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0
fetch-tags: true
path: api
- name: Checkout api-go
uses: actions/checkout@v4
with:
repository: temporalio/api-go
ref: ${{ github.event.inputs.branch }}
submodules: true
path: api-go
- name: Validate inputs
env:
BRANCH: ${{ github.event.inputs.branch }}
TAG: ${{ github.event.inputs.tag }}
BASE_TAG: ${{ github.event.inputs.base_tag }}
working-directory: ./api
run: |
if ! [[ "${TAG}" =~ ^v.* ]]; then
echo "::error::Tag is not prefixed with 'v'"
exit 1
fi
if [[ -n "$(git tag -l "$TAG")" ]]; then
echo "::error::Tag already exists"
exit 1
fi
if [[ -z "$BASE_TAG" || -z "$(git tag -l "$BASE_TAG")" ]]; then
echo "::error::Base tag not specified or does not exist"
exit 1
fi
- name: Pin commits sha
id: pin_commits
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: ${{ github.event.inputs.branch }}
run: |
API_COMMIT_SHA=$(git -C ./api rev-parse HEAD)
API_GO_COMMIT_SHA=$(git -C ./api-go rev-parse HEAD)
API_GO_API_COMMIT_SHA=$(git -C ./api-go rev-parse HEAD:proto/api)
if [[ "${API_GO_API_COMMIT_SHA}" != "${API_COMMIT_SHA}" ]]; then
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."
exit 1
fi
echo "api_commit_sha=$API_COMMIT_SHA" >> "$GITHUB_OUTPUT"
echo "api_go_commit_sha=$API_GO_COMMIT_SHA" >> "$GITHUB_OUTPUT"
check-compatibility-sdk-go:
needs: prepare-inputs
if: ${{ github.event.inputs.skip_sdk_check == false || github.event.inputs.skip_sdk_check == 'false' }}
uses: temporalio/api-go/.github/workflows/check-sdk-compat.yml@master
with:
sdk_ref: latest
api_ref: ${{ needs.prepare-inputs.outputs.api_go_commit_sha }}
create-release:
name: "Create release"
needs: [prepare-inputs, check-compatibility-sdk-go]
if: |
!cancelled() &&
needs.prepare-inputs.result == 'success' &&
contains(fromJSON('["success", "skipped"]'), needs.check-compatibility-sdk-go.result)
runs-on: ubuntu-latest
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }}
private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare-inputs.outputs.api_commit_sha }}
token: ${{ steps.generate_token.outputs.token }}
- name: Create release
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
REF: ${{ needs.prepare-inputs.outputs.api_commit_sha }}
TAG: ${{ github.event.inputs.tag }}
BASE_TAG: ${{ github.event.inputs.base_tag }}
run: |
gh repo set-default ${{ github.repository }}
gh release create "$TAG" --target "$REF" --latest --generate-notes --notes-start-tag "$BASE_TAG" --draft
release-api-go:
needs: [prepare-inputs, create-release]
if: |
!cancelled() &&
needs.create-release.result == 'success'
uses: temporalio/api-go/.github/workflows/create-release.yml@master
with:
ref: ${{ needs.prepare-inputs.outputs.api_go_commit_sha }}
tag: ${{ github.event.inputs.tag }}
api_commit_sha: ${{ needs.prepare-inputs.outputs.api_commit_sha }}
base_tag: ${{ github.event.inputs.base_tag }}
secrets: inherit