-
Notifications
You must be signed in to change notification settings - Fork 24
109 lines (106 loc) · 3.58 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
name: Release
on:
workflow_call:
defaults:
run:
shell: bash # Convenience workaround for Windows.
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux-x86_64
- os: windows-latest
target: windows-x86_64
# Apple targets are not properly signed. Users will have to mark the binaries as secure manually.
- os: macos-13
target: macos-x86_64
- os: macos-latest
target: macos-arm64
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install dependencies
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
cargo install cargo-deb
- name: Build
run: |
cargo build --release --verbose
if [[ $RUNNER_OS == "Linux" ]]; then
cargo appimage
cargo deb
fi
- name: Prepare artifacts
run: |
mkdir "${{ matrix.target }}"
artifact=wthrr-${{ matrix.target }}
binary=wthrr
if [[ $RUNNER_OS == "Windows" ]]; then
ext=.exe
elif [[ $RUNNER_OS == "Linux" ]]; then
mv ./target/appimage/wthrr.AppImage "./${{ matrix.target }}/$artifact.AppImage"
mv ./target/debian/wthrr*.deb "./${{ matrix.target }}/$artifact.deb"
fi
mv "./target/release/$binary$ext" "./${{ matrix.target }}/$artifact$ext"
ls ${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: wthrr-${{ matrix.target }}
path: ${{ matrix.target }}/wthrr*
- name: Prepare release
if: >
github.repository_owner == 'ttytm'
&& ((github.ref_name == 'main' && github.event_name == 'push') || github.ref_type == 'tag')
run: |
if [ "$GITHUB_REF_TYPE" == tag ]; then
{
echo "TAG=$GITHUB_REF_NAME";
echo "TITLE=wthrr ${GITHUB_REF_NAME:1}"; # v1.0.0 -> wthrr 1.0.0
} >> "$GITHUB_ENV"
else
{
echo "IS_PRERELEASE=true";
echo "TAG=nightly";
echo "TITLE=nightly build $(date -u +'%Y-%m-%d %H:%M:%S UTC')";
echo "BODY=Generated from commit $GITHUB_SHA.";
} >> "$GITHUB_ENV"
fi
- name: Update nightly tag
if: env.IS_PRERELEASE
uses: richardsimko/update-tag@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
- name: Release
if: >
github.repository_owner == 'ttytm'
&& ((github.ref_name == 'main' && github.event_name == 'push') || github.ref_type == 'tag')
uses: softprops/action-gh-release@v2
with:
files: ${{ matrix.target }}/wthrr*
tag_name: ${{ env.TAG }}
body: ${{ env.BODY }}
name: ${{ env.TITLE }}
prerelease: ${{ env.IS_PRERELEASE }}