Skip to content

Commit 7d3c357

Browse files
authored
feat: Build out Craft release flow (#50)
Builds the release flow for prevent cli using [Craft](https://github.com/getsentry/craft) via [`action-prepare-release`](https://github.com/getsentry/action-prepare-release) and the [getsentry/publish](https://github.com/getsentry/publish) repo for release management. This is the resulting flow: ### On workflow dispatch with version number: - commits result of `scripts/bump_version.sh` to new `release/$version` - opens issue on getsentry/publish (example: getsentry/publish#5871) ### On creation of that release/* branch: - build assets and upload as workflow artifacts (not release artifacts yet) ### On 'accepted' label applied in publish repo issue: IF assets are all present and checks are passing: - craft merges release branch into main - craft publishes prevent-cli to release targets (github release, pypi) - a separate workflow publishes codecov-cli like we do today (no craft) (github release, pypi, gcs)
1 parent 327cbef commit 7d3c357

17 files changed

Lines changed: 605 additions & 327 deletions

.craft.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ github:
44

55
changelogPolicy: auto
66

7+
requireNames:
8+
- sentry-prevent-cli_wheel
9+
- sentry-prevent-cli_alpine_arm64
10+
- sentry-prevent-cli_alpine_x86_64
11+
- sentry-prevent-cli_linux_arm64
12+
- sentry-prevent-cli_linux_x86_64
13+
- sentry-prevent-cli_macos
14+
- sentry-prevent-cli_windows.exe
15+
716
targets:
817
# For direct binary downloads + shasum + shasum.sig
918
- name: github
1019
tagPrefix: v
20+
checksums:
21+
- algorithm: sha256
22+
includeNames: sentry-prevent-cli.*
1123

1224
# - name: pypi
13-
# - name: sentry-pypi
14-
# internalPypiRepo: getsentry/pypi

.github/workflows/build.yml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# This workflow builds both sentry-prevent-cli and codecov-cli on push to a
2+
# release/* branch. These are later released by Craft and another workflow,
3+
# respectively.
4+
name: Build and publish codecov-cli
5+
6+
on:
7+
push:
8+
branches:
9+
- "release/**"
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
build_for_pypi:
16+
permissions:
17+
contents: read
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
persist-credentials: false
23+
24+
- name: Install dependencies
25+
run: pip install uv
26+
27+
- name: Build codecov-cli sdist and bdist
28+
run: |
29+
cd codecov-cli
30+
uv build
31+
32+
- name: Build prevent-cli sdist and bdist
33+
run: |
34+
cd prevent-cli
35+
uv build
36+
37+
- name: Upload codecov-cli artifacts
38+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
39+
with:
40+
name: codecov-cli_wheel
41+
path: ./codecov-cli/dist/*
42+
43+
- name: Upload prevent-cli artifacts
44+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
45+
with:
46+
name: sentry-prevent-cli_wheel
47+
path: ./prevent-cli/dist/*
48+
49+
build_assets:
50+
name: Build ${{ matrix.os }} binaries
51+
runs-on: ${{ matrix.os }}
52+
strategy:
53+
fail-fast: true
54+
matrix:
55+
include:
56+
- os: macos-13
57+
TARGET: macos
58+
CMD_BUILD: >
59+
cd ./codecov-cli &&
60+
uv run pyinstaller --target-arch universal2 -F ./codecov_cli/main.py &&
61+
mv ./dist/main ./dist/codecovcli_macos &&
62+
cd ../prevent-cli &&
63+
uv run pyinstaller --target-arch universal2 -F ./src/prevent_cli/main.py &&
64+
mv ./dist/main ./dist/sentry-prevent-cli_macos
65+
OUT_FILE_SUFFIX: _macos
66+
ASSET_MIME: application/octet-stream
67+
68+
- os: windows-2022
69+
TARGET: windows
70+
CMD_BUILD: >
71+
Set-Location .\codecov-cli &&
72+
uv run pyinstaller -F .\codecov_cli\main.py &&
73+
Move-Item -Path ".\dist\main.exe" -Destination ".\dist\codecovcli_windows.exe" &&
74+
Set-Location ..\prevent-cli &&
75+
uv run pyinstaller -F .\src\prevent_cli\main.py &&
76+
Move-Item -Path ".\dist\main.exe" -Destination ".\dist\sentry-prevent-cli_windows.exe"
77+
OUT_FILE_SUFFIX: _windows.exe
78+
ASSET_MIME: application/vnd.microsoft.portable-executable
79+
80+
steps:
81+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
82+
83+
- name: Set up Python 3.9
84+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
85+
with:
86+
python-version: "3.9"
87+
88+
- name: Install dependencies
89+
run: |
90+
pip install uv
91+
cd prevent-cli
92+
# Need to build pyyaml and ijson from sdists to get universal2 macos build to work
93+
uv sync --no-binary-package pyyaml --no-binary-package ijson
94+
cd ../codecov-cli
95+
uv sync --no-binary-package pyyaml --no-binary-package ijson
96+
97+
- name: Build with pyinstaller for ${{matrix.TARGET}}
98+
run: ${{matrix.CMD_BUILD}}
99+
100+
- name: Upload codecovcli binary for ${{matrix.TARGET}}
101+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
102+
with:
103+
name: codecovcli${{matrix.OUT_FILE_SUFFIX}}
104+
path: ./codecov-cli/dist/codecovcli${{matrix.OUT_FILE_SUFFIX}}
105+
106+
- name: Upload sentry-prevent-cli binary for ${{matrix.TARGET}}
107+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
108+
with:
109+
name: sentry-prevent-cli${{matrix.OUT_FILE_SUFFIX}}
110+
path: ./prevent-cli/dist/sentry-prevent-cli${{matrix.OUT_FILE_SUFFIX}}
111+
112+
build_linux_assets:
113+
name: Build ${{ matrix.distro_name }}_${{ matrix.arch }} binary
114+
runs-on: ${{ matrix.runs-on }}
115+
strategy:
116+
matrix:
117+
include:
118+
- distro: "alpine:3.14" # alpine 3.14 needed for musl 1.2.2/python 3.9 compatibility
119+
arch: arm64
120+
distro_name: alpine
121+
runs-on: ubuntu-24.04-arm
122+
- distro: "alpine:3.14"
123+
arch: x86_64
124+
distro_name: alpine
125+
runs-on: ubuntu-24.04
126+
- distro: "ubuntu:20.04" # ubuntu 20.04 needed for glibc 2.31/python 3.9 compatibility
127+
arch: arm64
128+
distro_name: linux
129+
runs-on: ubuntu-24.04-arm
130+
- distro: "ubuntu:20.04"
131+
distro_name: linux
132+
arch: x86_64
133+
runs-on: ubuntu-24.04
134+
135+
steps:
136+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
137+
138+
- name: Run in Docker
139+
run: |
140+
docker run \
141+
--rm \
142+
-v $(pwd):/${{ github.workspace }} \
143+
-w ${{ github.workspace }} \
144+
--platform linux/${{ matrix.arch }} \
145+
${{ matrix.distro }} \
146+
./scripts/build_${{ matrix.distro_name }}.sh ${{ matrix.distro_name }}_${{ matrix.arch }}
147+
148+
- name: Upload codecovcli binary for ${{matrix.distro_name}}_${{ matrix.arch}}
149+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
150+
with:
151+
name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }}
152+
path: ./codecov-cli/dist/codecovcli_*
153+
154+
- name: Upload sentry-prevent-cli binary for ${{matrix.distro_name}}_${{ matrix.arch}}
155+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
156+
with:
157+
name: sentry-prevent-cli_${{ matrix.distro_name }}_${{ matrix.arch }}
158+
path: ./prevent-cli/dist/sentry-prevent-cli_*
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Create release
2+
3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: Version to release
12+
required: true
13+
14+
force:
15+
description: Force a release even when there are release-blockers (optional)
16+
required: false
17+
18+
merge_target:
19+
description: Target branch to merge into. Uses the default branch as a fallback (optional)
20+
required: false
21+
22+
jobs:
23+
release:
24+
runs-on: ubuntu-24.04
25+
name: "Release a new version"
26+
steps:
27+
- name: Get auth token
28+
id: token
29+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
30+
with:
31+
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
32+
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
33+
34+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
with:
36+
token: ${{ steps.token.outputs.token }}
37+
fetch-depth: 0
38+
39+
- name: Prepare release
40+
uses: getsentry/action-prepare-release@3cea80dc3938c0baf5ec4ce752ecb311f8780cdc # v1.6.4
41+
env:
42+
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
43+
with:
44+
version: ${{ github.event.inputs.version }}
45+
force: ${{ github.event.inputs.force }}
46+
merge_target: ${{ github.event.inputs.merge_target }}

.github/workflows/create_release.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/create_release_pr.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)