-
Notifications
You must be signed in to change notification settings - Fork 3
151 lines (131 loc) · 5.27 KB
/
Copy pathrelease.yml
File metadata and controls
151 lines (131 loc) · 5.27 KB
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
on:
release:
types: [published]
jobs:
release:
strategy:
matrix:
build:
- platform: darwin/universal
os: macos-latest
tag: darwin-universal
- arch: amd64
platform: linux/amd64
os: ubuntu-latest
tag: linux-amd64
- arch: amd64
platform: windows/amd64
os: windows-latest
tag: windows-amd64
- arch: amd64
platform: windows/amd64
os: windows-latest
tag: windows-portable-amd64
- arch: arm64
platform: windows/arm64
os: windows-latest
tag: windows-arm64
- arch: arm64
platform: windows/arm64
os: windows-latest
tag: windows-portable-arm64
runs-on: ${{ matrix.build.os }}
name: Release (${{ matrix.build.tag }})
steps:
- uses: actions/checkout@v4
- name: Normalize version tag
id: normalize_version
shell: bash
run: |
if [ -n "${{ github.event.release.tag_name }}" ]; then
version=$(echo ${{ github.event.release.tag_name }} | sed -e 's/v//g')
else
version="1.0.0"
fi
echo "version=$version" >> $GITHUB_OUTPUT
- uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Install wails
shell: bash
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.9.1
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20.8.0'
- name: Set up linux
if: runner.os == 'Linux'
shell: bash
run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev
- name: Set up Windows
if: runner.os == 'Windows'
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install nsis
- name: Build frontend
shell: bash
run: |
npm install -g npm
cd frontend && npm install
- name: Build wails app for Linux / macOS
if: runner.os == 'Linux' || runner.os == 'macOS'
shell: bash
run: wails build -platform ${{ matrix.build.platform }} -ldflags "-X main.version=v${{ steps.normalize_version.outputs.version }}"
- name: Build Windows NSIS installer (Normal)
if: runner.os == 'Windows' && startsWith(matrix.build.tag, 'windows-a')
shell: bash
run: wails build -platform ${{ matrix.build.platform }} -nsis -ldflags "-X main.version=v${{ steps.normalize_version.outputs.version }}"
- name: Build Windows NSIS installer (Portable)
if: runner.os == 'Windows' && startsWith(matrix.build.tag, 'windows-portable')
shell: bash
run: wails build -platform ${{ matrix.build.platform }} -nsis -ldflags "-X main.version=v${{ steps.normalize_version.outputs.version }} -X main.portablebuild=true"
# Packaging
- name: Package linux binaries
if: runner.os == 'Linux'
shell: bash
run: |
cd build/bin/
tar -czvf safelock-${{ matrix.build.tag }}.tar.gz safelock
- name: Compress macOS app
if: runner.os == 'macOS'
shell: bash
run: cd build/bin && zip -r safelock-${{ matrix.build.tag }}.zip Safelock.app
- name: Compress windows binary
if: runner.os == 'Windows' && startsWith(matrix.build.tag, 'windows-a')
run: Compress-Archive Safelock-${{ matrix.build.arch }}-installer.exe safelock-${{ matrix.build.tag }}.zip
working-directory: .\build\bin
- name: Compress windows binary (Portable)
if: runner.os == 'Windows' && startsWith(matrix.build.tag, 'windows-portable')
run: Compress-Archive safelock.exe safelock-${{ matrix.build.tag }}.zip
working-directory: .\build\bin
# Upload
- name: Get latest release from API
if: startsWith(github.ref, 'refs/tags/')
id: get_upload_url
shell: bash
run: |
curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/mrf345/safelock/releases" > /tmp/releases.json
url=$(jq -r '.[0].upload_url' /tmp/releases.json)
echo "url=$url" >> $GITHUB_OUTPUT
- name: Upload zip artifacts
if: ${{ runner.os != 'Linux' && startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARTIFACT_NAME: safelock-${{ matrix.build.tag }}
with:
upload_url: ${{ steps.get_upload_url.outputs.url }}
asset_path: ./build/bin/safelock-${{ matrix.build.tag }}.zip
asset_name: ${{ env.ARTIFACT_NAME }}.zip
asset_content_type: application/zip
- name: Upload linux artifacts
if: ${{ runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARTIFACT_NAME: safelock-${{ matrix.build.tag }}
with:
upload_url: ${{ steps.get_upload_url.outputs.url }}
asset_path: ./build/bin/safelock-${{ matrix.build.tag }}.tar.gz
asset_name: ${{ env.ARTIFACT_NAME }}.tar.gz
asset_content_type: application/gzip