-
Notifications
You must be signed in to change notification settings - Fork 4
156 lines (134 loc) · 4.1 KB
/
release.yaml
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
# Modified from https://github.com/SpectralOps/rust-ci-release-template
name: Release
on:
push:
tags:
- "*.*.*"
- "*.*.*-pre.*"
permissions:
contents: write
env:
BIN_NAME: rss-funnel
PROJECT_NAME: rss-funnel
REPO_NAME: shouya/rss-funnel
jobs:
build:
name: Dist
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
cross: false
- os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-musl
cross: true
- os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
- os: windows-2019
rust: stable
target: x86_64-pc-windows-msvc
cross: false
- os: macos-latest
rust: stable
target: aarch64-apple-darwin
cross: false
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 8.14.x
- name: Build inspector front-end
run: |
cd inspector
pnpm install
pnpm run build
- name: Install ${{ matrix.rust }} toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Install musl build tools
# https://github.com/rust-lang/backtrace-rs/issues/34
# required for any musl targets
if: ${{ endsWith(matrix.target, '-musl') }}
run: sudo apt-get install -y musl-tools
- name: Run cargo test
uses: actions-rs/cargo@v1
# binary incompatible with aarch64-macos on host
if: ${{ matrix.target != 'aarch64-apple-darwin' }}
with:
use-cross: ${{ matrix.cross }}
command: test
args: --release --locked --target ${{ matrix.target }}
- name: Build release binary
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --release --locked --target ${{ matrix.target }}
- name: Parse release version
shell: bash
run: |
if [[ "$GITHUB_REF" =~ ^refs/tags/* ]]; then
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
else
echo "No tag found"
exit 1
fi
- name: Set DIST_BINARY
shell: bash
run: |
set -ex
dist_binary="target/${{ matrix.target }}/release/$BIN_NAME"
case "${{ matrix.target }}" in
*-windows-* )
dist_binary="$dist_binary.exe"
;;
esac
echo "DIST_BINARY=$dist_binary" >> $GITHUB_ENV
- name: Build archive
shell: bash
run: |
set -ex
mkdir -p dist
pkgname="${PROJECT_NAME}-$RELEASE_VERSION-${{matrix.target}}"
archive_dir="archive/$pkgname"
mkdir -p "$archive_dir"
cp -a LICENSE README.org "$archive_dir/"
mv "$DIST_BINARY" "$archive_dir/"
cd archive
case "${{ matrix.target }}" in
*-windows-*)
7z a -r ../dist/$pkgname.zip $pkgname
echo "PKG_NAME=$pkgname.zip" >> $GITHUB_ENV
echo "PKG_PATH=dist/$pkgname.zip" >> $GITHUB_ENV
;;
*)
tar cJf ../dist/$pkgname.tar.xz $pkgname
echo "PKG_NAME=$pkgname.tar.xz" >> $GITHUB_ENV
echo "PKG_PATH=dist/$pkgname.tar.xz" >> $GITHUB_ENV
;;
esac
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: "${{ env.PKG_NAME }}"
path: "${{ env.PKG_PATH }}"
- name: Publish archives
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
${{ env.PKG_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}