-
Notifications
You must be signed in to change notification settings - Fork 16
165 lines (145 loc) · 6.02 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
# The way this works is the following:
#
# The get-release job fetches the upload_url for the following job.
#
# The build-release job runs only once create-release is finished. It gets the
# release upload URL from create-release job outputs, then builds the release
# executables for each supported platform and attaches them as release assets
# to the previously created release.
name: Release
env:
CICD_INTERMEDIATES_DIR: "_cicd-intermediates"
MSRV_FEATURES: --no-default-features --features minimal-application,bugreport,build-assets
on:
push:
# Enable when testing release infrastructure on a branch.
branches:
- fix/release-ci-after-voice
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
jobs:
get-release:
name: get-release
runs-on: ubuntu-latest
# env:
# # Set to force version number, e.g., when no tag exists.
# SMARTCAT_VERSION: TEST-0.0.0
outputs:
smartcat_version: ${{ env.SMARTCAT_VERSION }}
steps:
- uses: actions/checkout@v4
- name: Get the release version from the tag
shell: bash
if: env.SMARTCAT_VERSION == ''
run: |
echo "SMARTCAT_VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV
echo "version is: ${{ env.SMARTCAT_VERSION }}"
build-release:
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
needs:
- get-release
strategy:
fail-fast: false
matrix:
job:
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
# - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true }
# - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true }
- { target: i686-pc-windows-msvc , os: windows-2019 }
- { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
- { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
- { target: x86_64-apple-darwin , os: macos-12 }
- { target: x86_64-pc-windows-gnu , os: windows-2019 }
- { target: x86_64-pc-windows-msvc , os: windows-2019 }
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
- { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
env:
BUILD_CMD: cargo
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.job.target }} in
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
esac
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.job.target }}
- name: Install cross
if: matrix.job.use-cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Overwrite build command env variable
if: matrix.job.use-cross
shell: bash
run: echo "BUILD_CMD=cross" >> $GITHUB_ENV
- name: Show version information (Rust, cargo, GCC)
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
- name: Build
shell: bash
run: $BUILD_CMD build --release --target=${{ matrix.job.target }}
- name: Set binary name & path
id: bin
shell: bash
run: |
# Figure out suffix of binary
EXE_SUFFIX=""
case ${{ matrix.job.target }} in
*-pc-windows-*) EXE_SUFFIX=".exe" ;;
esac;
# Setup paths
BIN_NAME="sc${EXE_SUFFIX}"
BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}"
# Let subsequent steps know where to find the binary
echo "BIN_PATH=${BIN_PATH}" | tee -a $GITHUB_OUTPUT
echo "BIN_NAME=${BIN_NAME}" | tee -a $GITHUB_OUTPUT
- name: Build archive
id: package
shell: bash
run: |
PKG_SUFFIX=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_SUFFIX=".zip" ;; esac;
PKG_BASENAME="sc-${{ needs.crate-metadata.outputs.version }}-${{ matrix.job.target }}"
PKG_NAME=${PKG_BASENAME}${PKG_SUFFIX}
echo "PKG_NAME=${PKG_NAME}" | tee -a $GITHUB_OUTPUT
PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package"
ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/"
mkdir -p "${ARCHIVE_DIR}"
# Binary
cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR"
# README, LICENSE and CHANGELOG files
cp "README.md" "LICENSE" "$ARCHIVE_DIR"
# base compressed package
pushd "${PKG_STAGING}/" >/dev/null
case ${{ matrix.job.target }} in
*-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;;
*) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;;
esac;
popd >/dev/null
# sha
pushd "${PKG_STAGING}/" >/dev/null
case ${{ matrix.job.target }} in
*-pc-windows-*) certutil -hashfile "${PKG_NAME}" SHA256 > "${PKG_NAME}.sha256" ;;
*) shasum -a 256 "${PKG_NAME}" > "${PKG_NAME}.sha256" ;;
esac;
popd >/dev/null
# Let subsequent steps know where to find the compressed package
echo "ASSET_PATH=${PKG_STAGING}/${PKG_NAME}" | tee -a $GITHUB_ENV
echo "ASSET_SUM=${PKG_STAGING}/${PKG_NAME}.sha256" | tee -a $GITHUB_ENV
# - name: Upload release archive
# env:
# GH_TOKEN: ${{ github.token }}
# run: gh release upload ${{ needs.get-release.outputs.smartcat_version }} ${{ env.ASSET_PATH }} ${{ env.ASSET_SUM }}