Skip to content

Commit 3ff19f2

Browse files
committed
fix(ci): use gh release and rm unused nightly logic
1 parent 4643da6 commit 3ff19f2

File tree

1 file changed

+31
-98
lines changed

1 file changed

+31
-98
lines changed

.github/workflows/release.yml

+31-98
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
push:
77
branches:
88
- main
9-
workflow_dispatch:
109

1110
env:
1211
CARGO_TERM_COLOR: always
@@ -30,44 +29,29 @@ jobs:
3029
with:
3130
pull_token: ${{ secrets.PULL_TOKEN }}
3231

33-
# If it's a nightly release, tag with the release time. If the tag is `main`,
34-
# we want to use the version from the `Cargo.toml` file.
3532
- name: Compute release name and tag
3633
id: release_info
3734
run: |
38-
if [[ $IS_NIGHTLY ]]; then
39-
echo "tag_name=nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT
40-
echo "release_name=Nightly ($(date '+%Y-%m-%d'))" >> $GITHUB_OUTPUT
41-
elif [[ "${GITHUB_REF_NAME}" == "main" ]]; then
42-
# Parse the version from the `Cargo.toml` file.
43-
VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "sp1-build") | .version')
44-
45-
echo "tag_name=v${VERSION}" >> $GITHUB_OUTPUT
46-
echo "release_name=v${VERSION}" >> $GITHUB_OUTPUT
47-
else
48-
echo "tag_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
49-
echo "release_name=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
50-
fi
51-
52-
# Creates a tag for this release.
53-
- name: Create build-specific tag
54-
uses: actions/github-script@v7
55-
env:
56-
TAG_NAME: ${{ steps.release_info.outputs.tag_name }}
57-
with:
58-
script: |
59-
const createTag = require('./.github/scripts/create-tag.js')
60-
await createTag({ github, context }, process.env.TAG_NAME)
35+
# Parse the version from the `Cargo.toml` file.
36+
VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "sp1-build") | .version')
37+
echo "tag_name=v${VERSION}" >> $GITHUB_OUTPUT
38+
echo "release_name=v${VERSION}" >> $GITHUB_OUTPUT
6139
6240
- name: Build changelog
6341
id: build_changelog
6442
uses: mikepenz/release-changelog-builder-action@v4
6543
with:
66-
fromTag: ${{ env.IS_NIGHTLY && 'nightly' || '' }}
6744
toTag: ${{ steps.release_info.outputs.tag_name }}
6845
env:
6946
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7047

48+
- name: Create release
49+
id: create_release
50+
env:
51+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
run: |
53+
gh release create ${{ steps.release_info.outputs.tag_name }} --target main --latest --notes ${{ steps.build_changelog.outputs.changelog }}
54+
7155
release:
7256
name: ${{ matrix.target }} (${{ matrix.runner }})
7357
runs-on: ${{ matrix.runner }}
@@ -109,24 +93,11 @@ jobs:
10993
steps:
11094
- uses: actions/checkout@v4
11195

112-
- name: Install rust toolchain
113-
id: rustc-toolchain
114-
uses: actions-rs/toolchain@v1
115-
with:
116-
toolchain: stable
117-
profile: minimal
118-
override: true
119-
targets: ${{ matrix.target }}
120-
121-
- uses: Swatinem/rust-cache@v2
122-
with:
123-
key: ${{ matrix.target }}
124-
cache-on-failure: true
125-
126-
- name: Install go
127-
uses: actions/setup-go@v5
96+
# Install rust and go.
97+
- name: Setup CI
98+
uses: ./.github/actions/setup
12899
with:
129-
go-version: "^1.22.1"
100+
pull_token: ${{ secrets.PULL_TOKEN }}
130101

131102
- name: Check go installation
132103
run: |
@@ -199,7 +170,7 @@ jobs:
199170
ARCH: ${{ matrix.arch }}
200171
# NOTE: SP1UP Relies on the version name being the tag name,
201172
# DO NOT CHANGE THIS WITHOUT UPDATING SP1UP TOO.
202-
VERSION_NAME: ${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }}
173+
VERSION_NAME: ${{ needs.prepare.outputs.tag_name }}
203174
shell: bash
204175
run: |
205176
if [ "$PLATFORM_NAME" == "linux" ]; then
@@ -217,33 +188,14 @@ jobs:
217188
echo "file_name=cargo_prove_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.zip" >> $GITHUB_OUTPUT
218189
fi
219190
220-
# Creates the release for this specific version
221-
# Note: If this CI job runs again on the same tag,
222-
# it will override the files there, but not change the commit to the current main.
223-
- name: Create release
224-
uses: softprops/action-gh-release@v2
225-
with:
226-
name: ${{ needs.prepare.outputs.release_name }}
227-
tag_name: ${{ needs.prepare.outputs.tag_name }}
228-
prerelease: ${{ env.IS_NIGHTLY }}
229-
body: ${{ needs.prepare.outputs.changelog }}
230-
files: |
231-
${{ steps.artifacts.outputs.file_name }}
232-
${{ steps.man.outputs.cargo_prove_man }}
233-
234-
# If this is a nightly release, it also updates the release
235-
# tagged `nightly` for compatibility with `sp1up`
236-
- name: Update nightly release
237-
if: ${{ env.IS_NIGHTLY }}
238-
uses: softprops/action-gh-release@v2
239-
with:
240-
name: "Nightly"
241-
tag_name: "nightly"
242-
prerelease: true
243-
body: ${{ needs.prepare.outputs.changelog }}
244-
files: |
245-
${{ steps.artifacts.outputs.file_name }}
246-
${{ steps.man.outputs.cargo_prove_man }}
191+
# Upload the artifacts to the release.
192+
- name: Upload Release artifact
193+
id: upload_release_artifact
194+
env:
195+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196+
run: |
197+
gh release upload ${{ needs.prepare.outputs.tag_name }} ${{ steps.artifacts.outputs.file_name }}
198+
247199
248200
toolchain-test:
249201
name: "Test toolchain installation (${{ matrix.name }})"
@@ -316,39 +268,16 @@ jobs:
316268
AWS_SG_ID: "${{ secrets.AWS_SG_ID }}"
317269
GH_PAT: ${{ secrets.GH_PAT }}
318270

319-
cleanup:
320-
name: Release cleanup
321-
runs-on: ubuntu-latest
322-
timeout-minutes: 30
323-
needs: release
324-
if: always()
325-
steps:
326-
- uses: actions/checkout@v4
327-
328-
# Moves the `nightly` tag to `HEAD`
329-
- name: Move nightly tag
330-
if: ${{ env.IS_NIGHTLY }}
331-
uses: actions/github-script@v7
332-
with:
333-
script: |
334-
const moveTag = require('./.github/scripts/move-tag.js')
335-
await moveTag({ github, context }, 'nightly')
336-
337-
- name: Delete old nightlies
338-
uses: actions/github-script@v7
339-
with:
340-
script: |
341-
const prunePrereleases = require('./.github/scripts/prune-prereleases.js')
342-
await prunePrereleases({github, context})
343-
344271
# If any of the jobs fail, this will create a high-priority issue to signal so.
345272
issue:
346273
name: Open an issue
347274
runs-on: ubuntu-latest
348-
needs: [prepare, release, cleanup]
275+
needs: [prepare, release]
349276
if: failure()
350277
steps:
351278
- uses: actions/checkout@v4
279+
280+
# todo remove this and use GH cli to create the issue
352281
- uses: JasonEtco/create-an-issue@v2
353282
env:
354283
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -357,3 +286,7 @@ jobs:
357286
with:
358287
update_existing: true
359288
filename: .github/RELEASE_FAILURE_ISSUE_TEMPLATE.md
289+
290+
- name: Delete failed release
291+
run: |
292+
gh release delete ${{ needs.prepare.outputs.tag_name }} --cleanup-tag

0 commit comments

Comments
 (0)