-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (117 loc) · 4.31 KB
/
main.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Release
on:
push:
branches:
- main
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check.outputs.should_release }}
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Check if Cargo.toml version changed
id: check
run: |
CURRENT_VERSION=$(grep -m1 version Cargo.toml | cut -d '"' -f2)
git checkout HEAD^1
PREVIOUS_VERSION=$(grep -m1 version Cargo.toml | cut -d '"' -f2)
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
echo "should_release=true" >> $GITHUB_OUTPUT
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
else
echo "should_release=false" >> $GITHUB_OUTPUT
fi
create-release:
needs: check-version
if: needs.check-version.outputs.should_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3
- name: Create Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.check-version.outputs.version }}
name: Release v${{ needs.check-version.outputs.version }}
draft: false
prerelease: false
build-release:
needs: [check-version, create-release]
if: needs.check-version.outputs.should_release == 'true'
strategy:
matrix:
os : [ubuntu-latest]
# os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
bin_path: target/x86_64-unknown-linux-gnu/release/xfce4-transparent-whiskermenu
asset_name: xfce4-transparent-whiskermenu-linux
# - os: windows-latest
# target: x86_64-pc-windows-msvc
# bin_path: target/x86_64-pc-windows-msvc/release/xfce4-transparent-whiskermenu.exe
# asset_name: xfce4-transparent-whiskermenu-windows.exe
# - os: macos-latest
# target: x86_64-apple-darwin
# bin_path: target/x86_64-apple-darwin/release/xfce4-transparent-whiskermenu
# asset_name: xfce4-transparent-whiskermenu-macos
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
- name: Generate SHA256
shell: bash
run: |
binary_path="target/${{ matrix.target }}/release/xfce4-transparent-whiskermenu"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
binary_path="target/${{ matrix.target }}/release/xfce4-transparent-whiskermenu.exe"
fi
if [ ! -f "$binary_path" ]; then
echo "Binary not found at $binary_path"
ls -la target/
ls -la target/${{ matrix.target }}/release/
exit 1
fi
if [ "${{ matrix.os }}" = "windows-latest" ]; then
sha256sum "$binary_path" > "$binary_path.sha256"
else
shasum -a 256 "$binary_path" > "$binary_path.sha256"
fi
- name: Upload Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ matrix.bin_path }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/octet-stream
- name: Upload SHA256
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ matrix.bin_path }}.sha256
asset_name: ${{ matrix.asset_name }}.sha256
asset_content_type: text/plain