blob: 009fc9c08fd212bd211ed6e14a8b7f362cd55ee2 (
plain)
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
|
name: Release
on:
push:
tags: [v*]
env:
CARGO_TERM_COLOR: always
defaults:
run:
shell: bash # necessary for windows
jobs:
lint:
uses: ./.github/workflows/lint.yml
build:
needs: lint
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin # not properly signed, so there are security warnings
os: macos-latest
- target: x86_64-pc-windows-gnu
os: windows-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
# - target: aarch64-unknown-linux-gnu
# os: ubuntu-latest
# - target: armv7-unknown-linux-gnueabihf
# os: ubuntu-latest
runs-on: ${{ matrix.os }}
env:
APP_NAME: wthrr
TARGET: ${{ matrix.target }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install and configure dependencies
# dependencies are only needed on ubuntu
# as that's the only place where we build the AppImage and would make cross-compilation
if: runner.os == 'Linux'
run: |
sudo apt-get install libfuse2
sudo wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" -O /usr/local/bin/appimagetool
sudo chmod +x /usr/local/bin/appimagetool
cargo install cargo-appimage
# sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf
# some additional configuration for cross-compilation on linux
# cat >>~/.cargo/config <<EOF
# [target.aarch64-unknown-linux-gnu]
# linker = "aarch64-linux-gnu-gcc"
# [target.armv7-unknown-linux-gnueabihf]
# linker = "arm-linux-gnueabihf-gcc"
# EOF
- name: Install rust target
run: rustup target add "$TARGET"
- name: Run build
run: |
cargo build --release --verbose --target "$TARGET"
if [[ $RUNNER_OS == "Linux" ]]; then
cargo appimage
fi
- name: Prepare artifacts
run: |
mkdir -p ./artifacts
if [[ $RUNNER_OS == "Windows" ]]; then
bin_file=$APP_NAME.exe
else
bin_file=$APP_NAME
fi
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
version=$GITHUB_REF_NAME
else
version=$GITHUB_SHA
fi
if [[ $RUNNER_OS == "Linux" ]]; then
mv ./wthrr-*-x86_64.AppImage "./artifacts/wthrr-$version-x86_64-linux.AppImage"
fi
# beautify release targets (remove '-unknown' / '-gnu' from filename)
artifact=$APP_NAME-$version-$(echo "$TARGET" | sed -e 's/-unknown//' -e 's/-gnu//')
mkdir "$artifact"
cp README.md LICENSE "$artifact/"
mv "./target/$TARGET/release/$bin_file" "./$artifact/$bin_file"
# compress
tar -czf "./artifacts/$artifact.tar.gz" "$artifact"
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: result
path: |
./artifacts
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: result
path: ./artifacts
- name: List
run: find ./artifacts
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ./artifacts/*.tar.gz, ./artifacts/*.AppImage
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Publish
run: cargo publish --token ${{ secrets.CRATES_TOKEN }}
|