Skip to content

Commit 7af5b43

Browse files
committed
chore(ci): add a release workflow building cargo-codspeed in the release
1 parent 3cc6bb8 commit 7af5b43

File tree

2 files changed

+75
-4
lines changed

2 files changed

+75
-4
lines changed

.github/workflows/release.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Release on tag
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
- uses: moonrepo/setup-rust@v0
19+
with:
20+
cache-target: release
21+
bins: cargo-workspaces
22+
- name: Build
23+
run: cargo build --release
24+
# - name: Publish package
25+
# run: cargo workspaces publish --from-git
26+
# env:
27+
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
28+
- name: Create a draft release
29+
id: create_release
30+
run: |
31+
NEW_VERSION=$(cargo workspaces ls --json | jq -r '.[] | select(.name == "codspeed") | .version')
32+
gh release create v$NEW_VERSION --title "v$NEW_VERSION" --generate-notes -d
33+
echo "upload_url=$(gh release view v$NEW_VERSION --json uploadUrl | jq -r '.uploadUrl')" >> $GITHUB_OUTPUT
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
37+
outputs:
38+
upload_url: ${{ steps.create_release.outputs.upload_url }}
39+
40+
build-upload-binaries:
41+
needs: publish
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
include:
46+
- target: x86_64-unknown-linux-gnu
47+
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v3
51+
- uses: moonrepo/setup-rust@v0
52+
with:
53+
targets: ${{ matrix.target }}
54+
cache-target: ${{ matrix.target }}/release
55+
56+
# TODO: Reenable when we have a way to build for other targets
57+
# - name: Setup environment for target
58+
# if: ${{ matrix.setup }}
59+
# run: ${{ matrix.setup }}
60+
61+
- run: cargo build --release --bin cargo-codspeed --target ${{ matrix.target }}
62+
63+
- name: Upload Release Asset
64+
id: upload-release-asset
65+
uses: actions/upload-release-asset@v1
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
with:
69+
upload_url: ${{ needs.publish.outputs.upload_url }}
70+
asset_path: ./target/${{ matrix.target }}/release/cargo-codspeed
71+
asset_name: cargo-codspeed-${{ matrix.target }}
72+
asset_content_type: application/octet-stream

scripts/release.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ if [ $# -ne 1 ]; then
77
exit 1
88
fi
99

10+
# Fail if not on main branch
11+
git branch --show-current | grep -q '^main$'
1012
# Fail if there are any unstaged changes left
1113
git diff --exit-code
1214

13-
cargo workspaces version $1
14-
NEW_VERSION=$(cargo workspaces ls --json | jq -r '.[] | select(.name == "codspeed") | .version')
15-
cargo workspaces publish --from-git
16-
gh release create v$NEW_VERSION --title "v$NEW_VERSION" --generate-notes -d
15+
cargo workspaces version --no-individual-tags $1

0 commit comments

Comments
 (0)