-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (162 loc) · 8.65 KB
/
package-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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Package
on:
release:
types: [published]
env:
REPO_NAME: thibaultmeyer/bingwallpaper
jobs:
linux-build:
name: Release for Linux
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Create Build Environment
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Build
working-directory: ${{github.workspace}}
shell: bash
run: cargo build --release
- name: Minify binary
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
ls -l bingwallpaper
strip bingwallpaper
ls -l bingwallpaper
- name: Rename file
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: mv bingwallpaper bingwallpaper-linux-$(uname -m)
- name: Checksum
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: cat bingwallpaper-linux-$(uname -m) | md5sum > bingwallpaper-linux-$(uname -m).md5
- name: Retrieve release ID
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
curl -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" https://api.github.com/repos/$REPO_NAME/releases | jq ".[].id" | head -n1 > release_id
- name: Upload binary
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
export RELEASE_ID=`cat release_id`
export FILE="bingwallpaper-linux-$(uname -m)"
export FILE_SIZE=`find $FILE -printf "%s"`
curl --request POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Content-Type: application/octet-stream" -H "Content-Length: $FILE_SIZE" \
--data-binary @$FILE "https://uploads.github.com/repos/$REPO_NAME/releases/$RELEASE_ID/assets?name=$FILE"
- name: Upload checksum
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
export RELEASE_ID=`cat release_id`
export FILE="bingwallpaper-linux-$(uname -m).md5"
export FILE_SIZE=`find $FILE -printf "%s"`
curl --request POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Content-Type: application/octet-stream" -H "Content-Length: $FILE_SIZE" \
--data-binary @$FILE "https://uploads.github.com/repos/$REPO_NAME/releases/$RELEASE_ID/assets?name=$FILE"
macos-build:
name: Release for MacOS
runs-on: macos-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Create Build Environment
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Build
working-directory: ${{github.workspace}}
shell: bash
run: cargo build --release
- name: Minify binary
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
ls -l bingwallpaper
strip bingwallpaper
ls -l bingwallpaper
- name: Rename file
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: mv bingwallpaper bingwallpaper-macos-$(uname -m)
- name: Checksum
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: cat bingwallpaper-macos-$(uname -m) | md5 > bingwallpaper-macos-$(uname -m).md5
- name: Retrieve release ID
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
curl -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" https://api.github.com/repos/$REPO_NAME/releases | jq ".[].id" | head -n1 > release_id
- name: Upload binary
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
export RELEASE_ID=`cat release_id`
export FILE="bingwallpaper-macos-$(uname -m)"
export FILE_SIZE=`stat -f%z $FILE`
curl --request POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Content-Type: application/octet-stream" -H "Content-Length: $FILE_SIZE" \
--data-binary @$FILE "https://uploads.github.com/repos/$REPO_NAME/releases/$RELEASE_ID/assets?name=$FILE"
- name: Upload checksum
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
export RELEASE_ID=`cat release_id`
export FILE="bingwallpaper-macos-$(uname -m).md5"
export FILE_SIZE=`stat -f%z $FILE`
curl --request POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Content-Type: application/octet-stream" -H "Content-Length: $FILE_SIZE" \
--data-binary @$FILE "https://uploads.github.com/repos/$REPO_NAME/releases/$RELEASE_ID/assets?name=$FILE"
windows-build:
name: Release for Windows
runs-on: windows-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Create Build Environment
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- name: Build
shell: pwsh
run: cargo build --release
- name: Add Icon
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
curl -L -o resource_hacker.zip http://www.angusj.com/resourcehacker/resource_hacker.zip
unzip resource_hacker.zip
./ResourceHacker.exe -open bingwallpaper.exe -save with_icon.exe -action addskip -res ../../res/icon/gallery-256-win-icon.ico -mask ICONGROUP,MAINICON,
- name: Rename file
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: mv with_icon.exe bingwallpaper-windows-$(uname -m).exe
- name: Checksum
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: cat bingwallpaper-windows-$(uname -m).exe | md5sum > bingwallpaper-windows-$(uname -m).md5
- name: Retrieve release ID
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
curl -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" https://api.github.com/repos/$REPO_NAME/releases | jq ".[].id" | head -n1 > release_id
- name: Upload binary
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
export RELEASE_ID=`cat release_id`
export FILE="bingwallpaper-windows-$(uname -m).exe"
export FILE_SIZE=`find $FILE -printf "%s"`
curl --request POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Content-Type: application/octet-stream" -H "Content-Length: $FILE_SIZE" \
--data-binary @$FILE "https://uploads.github.com/repos/$REPO_NAME/releases/$RELEASE_ID/assets?name=$FILE"
- name: Upload checksum
working-directory: ${{github.workspace}}/target/release/
shell: bash
run: |
export RELEASE_ID=`cat release_id`
export FILE="bingwallpaper-windows-$(uname -m).md5"
export FILE_SIZE=`find $FILE -printf "%s"`
curl --request POST -H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" -H "Content-Type: application/octet-stream" -H "Content-Length: $FILE_SIZE" \
--data-binary @$FILE "https://uploads.github.com/repos/$REPO_NAME/releases/$RELEASE_ID/assets?name=$FILE"