-
Notifications
You must be signed in to change notification settings - Fork 3
134 lines (114 loc) · 4.53 KB
/
build_and_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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Build and Release
on:
push:
branches: ["master"]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build-win-x64:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: Swatinem/rust-cache@v2
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features
- name: Get version and rename file to version specific
run: |
$tmversion = ./target/release/tmaze.exe --version | Select-String -Pattern '^tmaze ([0-9]+\.[0-9]+\.[0-9]+)$' | %{$_.Matches[0].Groups[1].Value}
$filepath = "./target/release/tmaze-${tmversion}-win-x86_64.exe"
echo "BIN_FILEPATH=$filepath" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
echo "TM_VERSION=$tmversion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
mv ./target/release/tmaze.exe ${filepath}
- run: echo "$Env:GITHUB_CONTEXT"
- uses: actions/upload-artifact@v3
with:
path: ${{env.BIN_FILEPATH}}
name: release
build-linux-x64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- run: sudo apt install libasound2-dev
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features
- run: strip ./target/release/tmaze
- run: ls -l ./target/release/
- run: |
versionregex="tmaze ([0-9]+\.[0-9]+\.[0-9]+)"
if [[ $(./target/release/tmaze --version) =~ $versionregex ]]; then
version=${BASH_REMATCH[1]}
filepath="./target/release/tmaze-$version-linux-x86_64"
echo "BIN_FILEPATH=$filepath" >> $GITHUB_ENV
echo "TM_VERSION=$version" >> $GITHUB_ENV
echo $version > ./target/release/version
mv ./target/release/tmaze $filepath
else
echo "FAIL"
fi
- uses: actions/upload-artifact@v3
with:
path: |
${{env.BIN_FILEPATH}}
./target/release/version
name: release
draft-release:
needs: ["build-win-x64", "build-linux-x64"]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
path: release-files/
name: release
- run: find ./release-files/ -type f -name "linux" -exec chmod +x ./release-files/{} \;
- run: ls ./release-files/
- name: Save version to env
run: |
version=$(<./release-files/version)
echo "TM_VERSION=$version" >> $GITHUB_ENV
- name: Remove version file
run: rm ./release-files/version
- uses: ncipollo/release-action@v1
with:
artifacts: "./release-files/*"
token: ${{ secrets.GITHUB_TOKEN }}
commit: master
generateReleaseNotes: true
skipIfReleaseExists: true
allowUpdates: true
draft: true
tag: ${{ env.TM_VERSION }}
publish-on-crates:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: sudo apt install libasound2-dev
- name: publish cmaze
uses: katyo/publish-crates@v2
with:
path: ./cmaze
registry-token: ${{ secrets.CRATES_IO }}
ignore-unpublished-changes: true
- name: publish tmaze
uses: katyo/publish-crates@v2
with:
path: ./tmaze
registry-token: ${{ secrets.CRATES_IO }}
ignore-unpublished-changes: true