-
Notifications
You must be signed in to change notification settings - Fork 3
102 lines (86 loc) · 3.18 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
name: Build and Release
on:
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-pc-windows-gnu
# - aarch64-pc-windows-gnu
# - x86_64-unknown-linux-gnu
# - x86_64-apple-darwin
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Extract Package Version"
id: cargo-version
run: |
version=v$(grep -oP 'version\s*=\s*"\K[0-9]+\.[0-9]+\.[0-9]+' dygma-layer-switcher/Cargo.toml | head -n 1)
echo "PACKAGE_VERSION=$version"
echo "PACKAGE_VERSION=$version" >> $GITHUB_ENV
- name: "Set up Rust"
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: "Update Package List"
run: sudo apt-get update -y
- name: "Install Dependencies"
run: sudo apt-get install -y mingw-w64 libudev-dev zip wine64
- name: "Build"
run: cargo build --release --target ${{ matrix.target }}
- name: "Zip"
run: |
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
executable_name="dygma-layer-switcher.exe"
cp target/${{ matrix.target }}/release/$executable_name .
mv $executable_name "Dygma Layer Switcher.exe"
zip dls-${{ env.PACKAGE_VERSION }}-${{ matrix.target }}.zip "Dygma Layer Switcher.exe"
else
executable_name="dygma-layer-switcher"
cp target/${{ matrix.target }}/release/$executable_name .
mv $executable_name "Dygma Layer Switcher"
zip dls-${{ env.PACKAGE_VERSION }}-${{ matrix.target }}.zip "Dygma Layer Switcher"
fi
env:
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
- name: "Upload Artifacts"
uses: actions/upload-artifact@v4
with:
path: dls-${{ env.PACKAGE_VERSION }}-${{ matrix.target }}.zip
name: dls-${{ env.PACKAGE_VERSION }}-${{ matrix.target }}.zip
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Extract Package Version"
id: cargo-version
run: |
version=v$(grep -oP 'version\s*=\s*"\K[0-9]+\.[0-9]+\.[0-9]+' dygma-layer-switcher/Cargo.toml | head -n 1)
echo "PACKAGE_VERSION=$version"
echo "PACKAGE_VERSION=$version" >> $GITHUB_ENV
- name: "Download Artifacts"
uses: actions/download-artifact@v4
with:
pattern: '**/dls-*.zip'
merge-multiple: true
path: .
- name: "Create Git Tag"
run: |
git config --local user.name "GitHub Action"
git config --local user.email "[email protected]"
git tag -a ${{ env.PACKAGE_VERSION }} -m "${{ env.PACKAGE_VERSION }}"
git push origin ${{ env.PACKAGE_VERSION }}
- name: "Create GitHub Release"
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.PACKAGE_VERSION }}
release_name: ${{ env.PACKAGE_VERSION }}
files: |
dls-${{ env.PACKAGE_VERSION }}-*.zip