-
Notifications
You must be signed in to change notification settings - Fork 20
194 lines (186 loc) · 7.65 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
name: Release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
workflow_dispatch:
inputs:
tag:
description: The tag to manually run a deploy for. (example tag `v1.2.3`)
required: true
prerelease:
description: |
Is this for a prerelease?
(for internal testing, not announced nor published to our brew tap)
(example tag `v1.2.3-beta.0`)
type: boolean
default: false
required: true
env:
CARGO_TERM_COLOR: always
jobs:
org-check:
name: Check GitHub Organization
if: ${{ github.repository_owner == 'pantsbuild' }}
runs-on: ubuntu-22.04
steps:
- name: Noop
run: "true"
determine-tag:
name: Determine the release tag to operate against.
needs: org-check
runs-on: ubuntu-22.04
outputs:
release-tag: ${{ steps.determine-tag.outputs.release-tag }}
release-version: ${{ steps.determine-tag.outputs.release-version }}
prerelease: ${{ steps.determine-tag.outputs.prerelease }}
steps:
- name: Determine Tag
id: determine-tag
run: |
if [[ -n "${{ github.event.inputs.tag }}" ]]; then
RELEASE_TAG=${{ github.event.inputs.tag }}
PRERELEASE=${{ github.event.inputs.prerelease }}
else
RELEASE_TAG=${GITHUB_REF#refs/tags/}
PRERELEASE=false
fi
if [[ "${RELEASE_TAG}" =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]] || [[ "${PRERELEASE}" == true ]]; then
echo "release-tag=${RELEASE_TAG}" >> $GITHUB_OUTPUT
echo "release-version=${RELEASE_TAG#v}" >> $GITHUB_OUTPUT
echo "prerelease=${PRERELEASE}" >> $GITHUB_OUTPUT
else
echo "::error::Release tag '${RELEASE_TAG}' must match 'v\d+.\d+.\d+' when not doing a pre-release."
exit 1
fi
github-release:
name: (${{ matrix.name }}) Create Github Release
needs: determine-tag
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-22.04
name: ubuntu-22.04
- os: [runs-on, runner=4cpu-linux-arm64, image=ubuntu22-full-arm64-python3.7-3.13, "run-id=${{ github.run_id }}"]
name: linux-arm64
- os: macOS-10.15-X64
name: macOS-10.15-X64
- os: macOS-11-ARM64
name: macOS-11-ARM64
environment: Release
steps:
- name: Checkout scie-pants ${{ needs.determine-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: ${{ needs.determine-tag.outputs.release-tag }}
- name: Package scie-pants ${{ needs.determine-tag.outputs.release-tag }} binary
if: ${{ matrix.os != 'ubuntu-22.04' && matrix.name != 'linux-arm64' }}
run: cargo run -p package -- --dest-dir dist/ scie
- name: Package scie-pants ${{ needs.determine-tag.outputs.release-tag }} binary
if: ${{ matrix.os == 'ubuntu-22.04' || matrix.name == 'linux-arm64' }}
run: |
cargo run -p package -- --dest-dir dist/ tools
docker run --rm \
-v $PWD:/code \
-w /code \
rust:1.76.0-alpine3.19 \
sh -c '
apk add cmake make musl-dev perl && \
cargo run -p package -- --dest-dir dist/ scie-pants
'
cargo run -p package -- --dest-dir dist/ scie \
--scie-pants dist/scie-pants --tools-pex dist/tools.pex
# Build up a draft release with the artifacts from each of these jobs:
- name: Create ${{ needs.determine-tag.outputs.release-tag }} Release
# Need to pull in https://github.com/softprops/action-gh-release/pull/316 to work-around
# double-release-creation that happens when attempting to update a draft release to
# not-draft.
uses: huonw/action-gh-release@998f80d5380609557d7464b01d59a10d845600a0 # v2.0.9 (v2) + https://github.com/softprops/action-gh-release/pull/316
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.determine-tag.outputs.release-tag }}
name: scie-pants ${{ needs.determine-tag.outputs.release-version }}
draft: true
# placeholder body to help someone track down why a release is still in draft:
body: "Release job in progress: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
files: dist/scie-pants-*
fail_on_unmatched_files: true
publish-announce-release:
name: Publish and Announce Release
needs:
- determine-tag
- github-release
runs-on: ubuntu-22.04
steps:
# Now, do the human-facing prep on the release (changelog etc.), and publish it
- name: Checkout scie-pants ${{ needs.determine-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: ${{ needs.determine-tag.outputs.release-tag }}
- name: Prepare Changelog
id: prepare-changelog
uses: a-scie/actions/[email protected]
with:
changelog-file: ${{ github.workspace }}/CHANGES.md
version: ${{ needs.determine-tag.outputs.release-version }}
setup-python: true
- name: Publish ${{ needs.determine-tag.outputs.release-tag }} Release
# See above for discussion:
uses: huonw/action-gh-release@998f80d5380609557d7464b01d59a10d845600a0 # v2.0.9 (v2) + https://github.com/softprops/action-gh-release/pull/316
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.determine-tag.outputs.release-tag }}
name: scie-pants ${{ needs.determine-tag.outputs.release-version }}
body_path: ${{ steps.prepare-changelog.outputs.changelog-file }}
draft: false
prerelease: ${{ needs.determine-tag.outputs.prerelease }}
discussion_category_name: Announcements
# Announce the release! Yay
- name: Post Release Announcement to Pants Slack `#announce`
if: ${{ needs.determine-tag.outputs.prerelease != 'true' }}
id: slack
uses: slackapi/[email protected]
with:
channel-id: "C18RRR4JK"
# N.B.: You can muck with the JSON blob and see the results rendered here:
# https://app.slack.com/block-kit-builder
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "The `pants` launcher binary (scie-pants) ${{ needs.determine-tag.outputs.release-tag }} is released:\n* https://github.com/pantsbuild/scie-pants/releases/tag/${{ needs.determine-tag.outputs.release-tag }}\n* https://www.pantsbuild.org/docs/installation"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
update-homebrew-tap:
name: Update pantsbuild/homebrew-tap
needs:
- determine-tag
- github-release
runs-on: ubuntu-22.04
steps:
- name: Bump `scie-pants` version in Casks/pants.rb to ${{ needs.determine-tag.outputs.release-tag }}
if: ${{ needs.determine-tag.outputs.prerelease != 'true' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.TAP_TOKEN }}
# Docs: https://octokit.github.io/rest.js/v19#actions-create-workflow-dispatch
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'pantsbuild',
repo: 'homebrew-tap',
workflow_id: 'release.yml',
ref: 'main',
inputs: {
tag: '${{ needs.determine-tag.outputs.release-tag }}'
}
})