-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (96 loc) · 4.15 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
name: Release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
permissions:
contents: write
jobs:
release:
name: release (${{ matrix.job.target }})
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
- { target: aarch64-apple-darwin, os: macos-latest }
# - { target: aarch64-pc-windows-gnu, os: ubuntu-latest }
# - { target: aarch64-pc-windows-msvc, os: windows-latest }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest }
- { target: aarch64-unknown-linux-musl, os: ubuntu-latest }
# - { target: arm-unknown-linux-gnueabi, os: ubuntu-latest }
# - { target: arm-unknown-linux-gnueabihf, os: ubuntu-latest }
# - { target: arm-unknown-linux-musleabi, os: ubuntu-latest }
# - { target: arm-unknown-linux-musleabihf, os: ubuntu-latest }
- { target: armv7-unknown-linux-gnueabi, os: ubuntu-latest }
- { target: armv7-unknown-linux-gnueabihf, os: ubuntu-latest }
- { target: armv7-unknown-linux-musleabi, os: ubuntu-latest }
- { target: armv7-unknown-linux-musleabihf, os: ubuntu-latest }
# - { target: i686-pc-windows-gnu, os: ubuntu-latest }
# - { target: i686-pc-windows-msvc, os: windows-latest }
# - { target: i686-unknown-linux-gnu, os: ubuntu-latest }
# - { target: i686-unknown-linux-musl, os: ubuntu-latest }
- { target: x86_64-apple-darwin, os: macos-latest }
- { target: x86_64-pc-windows-gnu, os: ubuntu-latest }
- { target: x86_64-pc-windows-msvc, os: windows-latest }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest }
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Cache
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.job.target }}-cargo-build-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.job.target }}-cargo-build-release-
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.job.target }}
- name: Install cross
run: cargo install --force cross
if: runner.os == 'Linux'
- name: Build
run: cargo build --locked --release --target=${{ matrix.job.target }}
if: runner.os != 'Linux'
- name: Build (cross)
run: cross build --locked --release --target=${{ matrix.job.target }}
if: runner.os == 'Linux'
- name: Archive
id: archive
shell: bash
run: |
# Set $BIN_NAME
case ${{ matrix.job.target }} in
*-pc-windows-*) BIN_NAME_SUFFIX='.exe' ;;
*) BIN_NAME_SUFFIX='' ;;
esac
BIN_NAME="vpm-repos-gen${BIN_NAME_SUFFIX}"
cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" .
# Set $ARCHIVE_PATH
RELEASE_VERSION="${GITHUB_REF#refs/tags/v}"
ARCHIVE_BASENAME="vpm-repos-gen-${RELEASE_VERSION}-${{ matrix.job.target }}"
case ${{ matrix.job.target }} in
*-pc-windows-*) ARCHIVE_SUFFIX='.zip' ;;
*) ARCHIVE_SUFFIX='.tar.gz' ;;
esac
ARCHIVE_PATH="${ARCHIVE_BASENAME}${ARCHIVE_SUFFIX}"
# Create archive
case ${{ matrix.job.target }} in
*-pc-windows-*) 7z a "${ARCHIVE_PATH}" "${BIN_NAME}" LICENSE-APACHE LICENSE-MIT README.md ;;
*) tar -czf "${ARCHIVE_PATH}" "${BIN_NAME}" LICENSE-APACHE LICENSE-MIT README.md ;;
esac
echo "ARCHIVE_PATH=${ARCHIVE_PATH}" >> "$GITHUB_ENV"
- name: Publish release
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
with:
files: ${{ env.ARCHIVE_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}