-
Notifications
You must be signed in to change notification settings - Fork 2
163 lines (129 loc) · 4.25 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
name: Release
on:
workflow_dispatch:
permissions:
contents: write
jobs:
get-version:
name: Get version from Cargo.toml
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get version from Cargo.toml
id: lookupVersion
uses: mikefarah/yq@8bf425b4d1344db7cd469a8d10a390876e0c77fd #v4.45.1
with:
cmd: yq -oy '"v" + .workspace.package.version' 'Cargo.toml'
- name: Print version
id: version
run: |
VERSION=${{ steps.lookupVersion.outputs.result }}
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
build-binaries:
name: Build ${{ matrix.target }}
needs: get-version
runs-on: ${{ matrix.os }}
env:
# Cross-compiled targets will override this to `cross`.
CARGO: cargo
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cross: true
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cross: true
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
cross: true
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@cross
- name: Enable cross-compilation
if: matrix.cross
shell: bash
run: |
echo "CARGO=cross" >> $GITHUB_ENV
- uses: actions/setup-go@v5
with:
go-version: 'stable'
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure cross and build
shell: bash
run: |
export PROTOC=$(which protoc)
path=$(which protoc)
cross_toml_content="
[build.env]
passthrough = [
\"PROTOC\"
]
volumes = [
\"PROTOC=${path}\"
]
"
printf "$cross_toml_content" >> Cross.toml
${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
set -euxo pipefail
PKG_FULL_NAME="cairo-profiler-${{ needs.get-version.outputs.version }}-${{ matrix.target }}"
echo "PKG_FULL_NAME=$PKG_FULL_NAME" >> $GITHUB_ENV
bash ./scripts/package.sh "${{ matrix.target }}" "$PKG_FULL_NAME"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.target }}
path: ${{ env.PKG_FULL_NAME }}.*
create-release:
name: Create release
runs-on: ubuntu-latest
needs: [ build-binaries, get-version ]
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts-dl
- name: Unpack artifacts to staging directory
run: |
mkdir -p artifacts
mv artifacts-dl/build-*/cairo-profiler-* artifacts/
- name: Create GitHub release
id: create-release
uses: taiki-e/create-gh-release-action@b7abb0cf5e72cb5500307b577f9ca3fd4c5be9d2 # v1.8.4
with:
token: ${{ secrets.GITHUB_TOKEN }}
changelog: CHANGELOG.md
allow-missing-changelog: true
title: $version
ref: refs/tags/${{ needs.get-version.outputs.version }}
- name: Upload artifacts to the release
working-directory: artifacts
run: gh release upload "$TAG" *
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.create-release.outputs.computed-prefix }}${{ steps.create-release.outputs.version }}