-
Notifications
You must be signed in to change notification settings - Fork 0
226 lines (201 loc) · 7.79 KB
/
release.yml
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: release
on:
workflow_dispatch:
inputs:
release:
description: 'is this an actual release?'
required: true
type: boolean
default: false
fail:
description: 'should a job fail?'
required: true
type: boolean
default: false
release-version:
required: true
type: string
default: asdf
new-version:
required: true
type: string
default: asdf
release-major-version:
required: true
type: number
default: 1
release-minor-version:
required: true
type: number
default: 50
release-patch-version:
required: true
type: number
default: 1
aeron-git-tag:
description: Aeron OSS git tag
required: true
default: origin/HEAD
type: string
schedule:
- cron: '0 12 * * *'
jobs: # these jobs run serially because of the 'needs:' keyword on each
validation:
runs-on: ubuntu-latest
outputs:
new-sha: ${{ steps.set-sha.outputs.new-sha }}
release-version: ${{ steps.version-check.outputs.release-version }}
create-branch: ${{ steps.version-check.outputs.create-branch }}
snapshot-version: ${{ steps.version-check.outputs.snapshot-version }}
new-branch: ${{ steps.version-check.outputs.new-branch }}
branch-snapshot-version: ${{ steps.version-check.outputs.branch-snapshot-version }}
steps:
- name: figure out versions
id: version-check
run: |
MAIN_BRANCH_REF="refs/heads/asdfmaster"
major=${{ inputs.release-major-version }}
minor=${{ inputs.release-minor-version }}
patch=${{ inputs.release-patch-version }}
let "minor_incr=minor+1"
let "patch_incr=patch+1"
echo $major $minor $patch
echo $minor_incr $patch_incr
echo "release-version=$major.$minor.$patch" >> "$GITHUB_OUTPUT"
[ "${{ github.ref }}" == "$MAIN_BRANCH_REF" ] && CREATE_BRANCH=true || CREATE_BRANCH=false
echo "create-branch=$CREATE_BRANCH" >> "$GITHUB_OUTPUT"
[ "${{ github.ref }}" == "$MAIN_BRANCH_REF" ] && SNAPSHOT_VERSION="$major.$minor_incr.$patch" || SNAPSHOT_VERSION="$major.$minor.$patch_incr"
echo "snapshot-version=$SNAPSHOT_VERSION-SNAPSHOT" >> "$GITHUB_OUTPUT"
NEW_BRANCH=""
[ "${{ github.ref }}" == "$MAIN_BRANCH_REF" ] && NEW_BRANCH="release-$major.$minor.$patch"
echo "new-branch=release-$NEW_BRANCH" >> "$GITHUB_OUTPUT"
BRANCH_SNAPSHOT_VERSION=""
[ "${{ github.ref }}" == "$MAIN_BRANCH_REF" ] && BRANCH_SNAPSHOT_VERSION="$major.$minor.$patch_incr-SNAPSHOT"
echo "branch-snapshot-version=$BRANCH_SNAPSHOT_VERSION" >> "$GITHUB_OUTPUT"
cat $GITHUB_OUTPUT
- if: ${{ inputs.release }}
id: release-yes
run: |
echo "NEW_SHA=yes${{ github.sha }}" >> "$GITHUB_ENV"
- if: ${{ !inputs.release }}
id: release-no
run: |
echo "NEW_SHA=no${{ github.sha }}" >> "$GITHUB_ENV"
- id: set-sha
run: |
echo "new-sha=$NEW_SHA" >> "$GITHUB_OUTPUT"
intermediate:
runs-on: ubuntu-latest
needs: validation
steps:
-
run: |
echo release version: ${{ needs.validation.outputs.release-version }}
echo create branch: ${{ needs.validation.outputs.create-branch }}
echo snapshot version: ${{ needs.validation.outputs.snapshot-version }}
echo new branch: ${{ needs.validation.outputs.new-branch }}
echo branch snapshot version: ${{ needs.validation.outputs.branch-snapshot-version }}
-
run: |
echo git sha: ${{ github.sha }}
echo new sha: ${{ needs.validation.outputs.new-sha }}
exit 1
ci: # kick off a different workflow - all the normal CI stuff can be neatly isolated
uses: ./.github/workflows/ci.yml
needs: intermediate
with:
fail: ${{ inputs.fail || false }}
# could add a 'capture-assets' boolean input option on CI so that it knows if/when to store artifacts for subsequent packaging
# The normal CI run won't need to store those artifacts - only when it's being run as a 'sub'-workflow of 'release'
package: # shows retrieving an artifact from the previous step
runs-on: ubuntu-latest
needs: ci # wait for the ci job to complete
steps:
- name: step1
run: echo "building some packages"
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: my-artifact
- name: ls
run: ls
tag: # shows how to add a tag to the git repo
runs-on: ubuntu-latest
needs: package # wait for package job to complete
# only execute if this is a release
if: ${{ inputs.release || false }}
outputs:
new-sha: ${{ steps.update-version.outputs.new-sha }} # used by the final-tag job
steps:
- name: checkout
uses: actions/checkout@v4
- name: output
run: |
echo "the current sha: $GITHUB_SHA"
- name: Create/update tag
uses: actions/github-script@v7
with:
# instead of the default GITHUB_TOKEN, this could be a separate token that only gives permission to add tags
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/release-run-${{ github.run_id }}',
sha: context.sha
})
- name: update the version file
id: update-version # need an 'id' here so we can grab the new-sha and store it as an output
# it's not really a 'version', but it's a value that changes with each run
run: |
echo "the ORIGINAL sha: `git rev-parse HEAD`"
echo ${{ github.run_id }} > version.txt
echo VERSION=${{ inputs.new-version }} >> version.txt
git config --global user.name "the 'release' github action"
git config --global user.email "[email protected]"
git add version.txt
git commit -m 'update version'
git push
echo "the NEW sha: `git rev-parse HEAD`"
echo "new-sha=`git rev-parse HEAD`" >> "$GITHUB_OUTPUT"
final-tag:
runs-on: ubuntu-latest
needs: tag
steps:
- name: Create/update tag 2
uses: actions/github-script@v7
with:
# instead of the default GITHUB_TOKEN, this could be a separate token that only gives permission to add tags
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/release-run-${{ github.run_id }}-POST',
sha: '${{needs.tag.outputs.new-sha}}'
})
# the single quotes are important!!!!
- name: create a file
run: echo "some data" > some.file
- name: create release
uses: softprops/action-gh-release@v2
with:
body: "put notable changes here"
target_commitish: ${{needs.tag.outputs.new-sha}}
generate_release_notes: true
name: "release ${{ github.run_number }}"
tag_name: 'release-run-${{ github.run_id }}'
files: |
some.file
push:
runs-on: ubuntu-latest
needs: package
steps:
- name: push to release
if: ${{ inputs.release || false }}
run: echo "this is where we'd push to the release repo"
- name: push to dev
if: ${{ !inputs.release || false }}
run: echo "this is where we'd push to the dev repo"
- name: validate packages
run: echo "validate whatever we find in packages/"