-
Notifications
You must be signed in to change notification settings - Fork 0
247 lines (230 loc) · 7.85 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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
name: Main
on:
push:
branches: [ "main" ]
tags:
- '*'
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: windows-latest
outputs:
VERSION: ${{ env.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Check out winrt-go fork
uses: actions/checkout@v4
with:
repository: balazsgrill/winrt-go
path: winrt-go
- name: Get release info
id: release_info
if: github.ref_type == 'tag'
uses: revam/gh-action-get-tag-and-version@v1
with:
tag: ${{ github.ref }}
prefix: v
prefixRegex: "[vV]?"
- id: set_version
uses: marcdomain/[email protected]
name: Set version
with:
variables: |
VERSION: '${{ github.ref_type }}' == 'tag' ? "${{ steps.release_info.outputs.version }}" : "0.0.0.0"
- run: echo "VERSION ${{ env.VERSION }}"
- name: enable Projection FS
run: Enable-WindowsOptionalFeature -Online -FeatureName Client-ProjFS -NoRestart
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Download and install thrift
run: |
$thriftUrl = 'https://dlcdn.apache.org/thrift/0.21.0/thrift-0.21.0.exe'
$thriftPath = Join-Path $env:RUNNER_TOOL_CACHE 'thrift.exe'
Invoke-WebRequest -Uri $thriftUrl -OutFile $thriftPath
echo "$env:RUNNER_TOOL_CACHE" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Get tools
run: |
go install github.com/akavel/rsrc@latest
go install github.com/minio/minio@latest
go install github.com/minio/mc@latest
- name: Generate
env:
NoDefaultCurrentDirectoryInExePath: 1
run: go generate ./...
- name: Test
run: go test -v ./...
- name: Set version to manifest
uses: rvolo/[email protected]
with:
filepath: "cmd/main/main.exe.manifest"
xpath: "//assembly/assemblyIdentity/@version"
replace: "${{ env.VERSION }}"
- name: Build
run: go build -o potatodrive.exe -ldflags="-H windowsgui -X 'main.Version=${{ env.VERSION }}'" ./cmd/main
- name: Compress
uses: crazy-max/ghaction-upx@v3
with:
version: latest
files: |
./potatodrive.exe
args: "-9"
- uses: actions/upload-artifact@v4
with:
name: potatodrive.exe
path: potatodrive.exe
- name: Build-proxy-amd64
env:
GOOS: "linux"
GOARCH: "amd64"
run: go build -o potatodrive-proxy-amd64 -ldflags="-X 'main.Version=${{ env.VERSION }}'" ./cmd/proxy
- uses: actions/upload-artifact@v4
with:
name: potatodrive-proxy-amd64
path: potatodrive-proxy-amd64
- name: Build-proxy-armhf
env:
GOOS: "linux"
GOARCH: "arm"
GOARM: "5"
run: go build -o potatodrive-proxy-armhf -ldflags="-X 'main.Version=${{ env.VERSION }}'" ./cmd/proxy
- uses: actions/upload-artifact@v4
with:
name: potatodrive-proxy-armhf
path: potatodrive-proxy-armhf
installer:
runs-on: windows-latest
needs: build
steps:
- uses: actions/checkout@v4
- run: echo "VERSION ${{ needs.build.outputs.VERSION }}"
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 5.x
- name: Install wix
run: |
dotnet tool install --global wix
- name: Substitute version
uses: bluwy/substitute-string-action@v3
with:
_input-file: PotatoDrive-vars.wxi.tpl
_output-file: PotatoDrive-vars.wxi
_format-key: '%%key%%'
Version: ${{ needs.build.outputs.VERSION}}
- uses: actions/upload-artifact@v4
with:
name: PotatoDrive-vars.wxi
path: PotatoDrive-vars.wxi
- uses: actions/download-artifact@v4
with:
name: potatodrive.exe
path: potatodrive.exe
- run: dir
- name: Create installer
run: wix build PotatoDrive.wxs -arch x64
- uses: actions/upload-artifact@v4
with:
name: PotatoDrive_${{ needs.build.outputs.VERSION}}.msi
path: PotatoDrive.msi
debian-packages:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- run: echo "VERSION ${{ needs.build.outputs.VERSION }}"
- name: Install tools
run: |
sudo apt update
sudo apt-get install -y build-essential devscripts debhelper gettext-base
- uses: actions/download-artifact@master
with:
name: potatodrive-proxy-amd64
path: ./cmd/proxy/potatodrive-proxy-amd64
- uses: actions/download-artifact@master
with:
name: potatodrive-proxy-armhf
path: ./cmd/proxy/potatodrive-proxy-armhf
- name: Package-armhf
working-directory: ./cmd/proxy
env:
VERSION: ${{ needs.build.outputs.VERSION }}
run: |
echo "Version: $VERSION"
envsubst < debian/changelog.tpl > debian/changelog
dpkg-buildpackage --target-arch armhf --host-arch armhf -b
- name: Package-amd64
working-directory: ./cmd/proxy
env:
VERSION: ${{ needs.build.outputs.VERSION }}
run: |
echo "Version: $VERSION"
envsubst < debian/changelog.tpl > debian/changelog
dpkg-buildpackage --target-arch amd64 --host-arch amd64 -b
- uses: actions/upload-artifact@v4
with:
name: "potatodrive-proxy_${{ needs.build.outputs.VERSION}}_armhf.deb"
path: "./cmd/potatodrive-proxy_${{ needs.build.outputs.VERSION}}_armhf.deb"
- uses: actions/upload-artifact@v4
with:
name: "potatodrive-proxy_${{ needs.build.outputs.VERSION}}_amd64.deb"
path: "./cmd/potatodrive-proxy_${{ needs.build.outputs.VERSION}}_amd64.deb"
release:
runs-on: ubuntu-latest
needs:
- installer
- debian-packages
- build
if: github.ref_type == 'tag'
steps:
- name: release
uses: ncipollo/release-action@v1
id: create_release
with:
allowUpdates: true
draft: false
prerelease: false
name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: actions/download-artifact@master
with:
name: PotatoDrive_${{ needs.build.outputs.VERSION}}.msi
path: PotatoDrive_${{ needs.build.outputs.VERSION}}.msi
- uses: actions/download-artifact@v1
with:
name: "potatodrive-proxy_${{ needs.build.outputs.VERSION}}_armhf.deb"
path: "potatodrive-proxy_${{ needs.build.outputs.VERSION}}_armhf.deb"
- uses: actions/download-artifact@v1
with:
name: "potatodrive-proxy_${{ needs.build.outputs.VERSION}}_amd64.deb"
path: "potatodrive-proxy_${{ needs.build.outputs.VERSION}}_amd64.deb"
- name: upload Installer
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: PotatoDrive_${{ env.VERSION}}.msi
asset_name: PotatoDrive-${{ env.VERSION }}.msi
asset_content_type: application/x-msi
- name: upload amd64 deb
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "potatodrive-proxy_${{ needs.build.outputs.VERSION}}_amd64.deb"
asset_name: "potatodrive-proxy_${{ needs.build.outputs.VERSION}}_amd64.deb"
asset_content_type: application/x-deb
- name: upload armhf deb
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "potatodrive-proxy_${{ needs.build.outputs.VERSION}}_armhf.deb"
asset_name: "potatodrive-proxy_${{ needs.build.outputs.VERSION}}_armhf.deb"
asset_content_type: application/x-deb