-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (76 loc) · 2.99 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
# Build Release Artifacts on Version Tag Push
# Heavily inspired by https://github.com/open-contracting/cardinal-rs/blob/main/.github/workflows/release.yml
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- env:
GH_TOKEN: ${{ github.token }}
run: gh release create ${{ github.ref_name }}
assets:
needs: release
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Include all "Tier 1 with Host Tools" targets and "Tier 2 with Host Tools" targets for Windows and macOS,
# excluding *-pc-windows-msvc, which requires cross-toolchains. Goal is one option per OS per architecture.
# https://doc.rust-lang.org/rustc/platform-support.html
# https://github.com/cross-rs/cross#supported-targets
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
include:
# 64-bit (x86)
- build: linux-64-bit
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
command: cross
- build: macos-64-bit
os: macos-latest
target: x86_64-apple-darwin
command: cargo
- build: windows-64-bit
os: ubuntu-latest
target: x86_64-pc-windows-gnu
command: cross
# 64-bit (ARM)
# aarch64-pc-windows-gnullvm is Tier 3.
- build: macos-arm-64-bit
os: macos-latest
target: aarch64-apple-darwin
command: cargo
- build: linux-arm-64-bit
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
command: cross
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- run: cargo install cross --git https://github.com/cross-rs/cross
- run: ${{ matrix.command }} build --release --target ${{ matrix.target }}
# 7z is available on all runners.
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#preinstalled-software
- name: Create archive
id: archive
run: |
PROJNAME="$( echo -n ${{ github.repository }} | sed -re 's/^.+\///' )"
BINNAME="$( echo -n ${PROJNAME} | tr '[:upper:]' '[:lower:]' )"
DIRECTORY="${PROJNAME}-${{ github.ref_name }}-${{ matrix.build }}"
if [[ "${{ matrix.target }}" =~ "-pc-windows-" ]]; then
SUFFIX=".exe"
else
SUFFIX=""
fi
mkdir "$DIRECTORY"
cp LICENSE Readme.md "target/${{ matrix.target }}/release/${BINNAME}${SUFFIX}" "$DIRECTORY"
7z a "$DIRECTORY.zip" "$DIRECTORY"
echo "path=$DIRECTORY.zip" >> $GITHUB_OUTPUT
- env:
GH_TOKEN: ${{ github.token }}
run: gh release upload ${{ github.ref_name }} ${{ steps.archive.outputs.path }}