-
Notifications
You must be signed in to change notification settings - Fork 8
165 lines (142 loc) · 7.65 KB
/
build.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
# yamllint disable rule:line-length
---
name: package
# yamllint disable-line rule:truthy
on:
push:
tags:
- "v*.*.*"
jobs:
package:
strategy:
matrix:
build-os: [ubuntu-latest, macOS-latest]
platform: [linux-amd64, windows-amd64, darwin-amd64, darwin-arm64]
runs-on: ${{ matrix.build-os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.21.3
- name: Checkout code
uses: actions/checkout@v2
- name: Install linux dependencies
if: ${{ matrix.build-os == 'ubuntu-latest' }}
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev build-essential pkg-config gcc-mingw-w64 zip
- name: Build packages windows-amd64
if: ${{ matrix.platform == 'windows-amd64' && matrix.build-os == 'ubuntu-latest' }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
echo "building for ${{ matrix.platform }}"
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -v -ldflags "-s -w -X github.com/SafetyCulture/safetyculture-exporter/internal/app/version.version=${{ github.ref_name }}" -o safetyculture-exporter.exe ./cmd/safetyculture-exporter/main.go
mkdir safetyculture-exporter-cli
cp safetyculture-exporter.exe README.md THIRD_PARTY_NOTICES.md safetyculture-exporter-cli/
zip -r safetyculture-exporter-windows-x86_64.zip safetyculture-exporter-cli
rm -rf safetyculture-exporter-cli
- name: Upload artifacts windows-amd64
if: ${{ matrix.platform == 'windows-amd64' && matrix.build-os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v2
with:
name: exporter-windows-amd64
path: safetyculture-exporter-windows-x86_64.zip
- name: Build package linux-amd64
if: ${{ matrix.platform == 'linux-amd64' && matrix.build-os == 'ubuntu-latest' }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
echo "building for ${{ matrix.platform }}"
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -v -ldflags "-s -w -X github.com/SafetyCulture/safetyculture-exporter/internal/app/version.version=${{ github.ref_name }}" -o safetyculture-exporter ./cmd/safetyculture-exporter/main.go
zip safetyculture-exporter_linux_x86_64.zip exporter-linux README.md THIRD_PARTY_NOTICES.md
mkdir safetyculture-exporter-cli
cp safetyculture-exporter README.md THIRD_PARTY_NOTICES.md safetyculture-exporter-cli/
zip -r safetyculture-exporter-linux-amd64.zip safetyculture-exporter-cli
rm -rf safetyculture-exporter-cli
- name: Upload artifacts linux-amd64
if: ${{ matrix.platform == 'linux-amd64' && matrix.build-os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v2
with:
name: exporter-linux-amd64
path: safetyculture-exporter-linux-amd64.zip
- name: Build package darwin-amd64
if: ${{ matrix.platform == 'darwin-amd64' && matrix.build-os == 'macOS-latest' }}
env:
MAC_SIGNING_CERT: ${{ secrets.MAC_SIGNING_CERT }}
run: |
echo "Importing certificates"
echo $MAC_SIGNING_CERT | base64 --decode > certificate.p12
security create-keychain -p ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
security import certificate.p12 -k build.keychain -P ${{ secrets.MAC_SIGNING_CERT_PASSWORD }} -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
export PATH=$PATH:$(go env GOPATH)/bin
echo "building for ${{ matrix.platform }}"
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -v -ldflags "-s -w -X github.com/SafetyCulture/safetyculture-exporter/internal/app/version.version=${{ github.ref_name }}" -o safetyculture-exporter ./cmd/safetyculture-exporter/main.go
echo "Code signing darwin/amd64"
codesign --force -s "${{ secrets.MAC_SIGNING_CERT_NAME }}" --options runtime ./safetyculture-exporter -v
mkdir safetyculture-exporter-cli
cp safetyculture-exporter README.md THIRD_PARTY_NOTICES.md safetyculture-exporter-cli/
zip -r safetyculture-exporter-darwin-amd64.zip safetyculture-exporter-cli
rm -rf safetyculture-exporter-cli
- name: Upload artifacts darwin-amd64
if: ${{ matrix.platform == 'darwin-amd64' && matrix.build-os == 'macOS-latest' }}
uses: actions/upload-artifact@v2
with:
name: exporter-darwin-amd64
path: safetyculture-exporter-darwin-amd64.zip
- name: Build package darwin-arm64
if: ${{ matrix.platform == 'darwin-arm64' && matrix.build-os == 'macOS-latest' }}
env:
MAC_SIGNING_CERT: ${{ secrets.MAC_SIGNING_CERT }}
run: |
echo "Importing certificates"
echo $MAC_SIGNING_CERT | base64 --decode > certificate.p12
security create-keychain -p ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
security import certificate.p12 -k build.keychain -P ${{ secrets.MAC_SIGNING_CERT_PASSWORD }} -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
export PATH=$PATH:$(go env GOPATH)/bin
echo "building for ${{ matrix.platform }}"
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -v -ldflags "-s -w -X github.com/SafetyCulture/safetyculture-exporter/internal/app/version.version=${{ github.ref_name }}" -o safetyculture-exporter ./cmd/safetyculture-exporter/main.go
echo "Code signing darwin/arm64"
codesign --force -s "${{ secrets.MAC_SIGNING_CERT_NAME }}" --options runtime ./safetyculture-exporter -v
mkdir safetyculture-exporter-cli
cp safetyculture-exporter README.md THIRD_PARTY_NOTICES.md safetyculture-exporter-cli/
zip -r safetyculture-exporter-darwin-arm64.zip safetyculture-exporter-cli
rm -rf safetyculture-exporter-cli
- name: Upload artifacts darwin-arm64
if: ${{ matrix.platform == 'darwin-arm64' && matrix.build-os == 'macOS-latest' }}
uses: actions/upload-artifact@v2
with:
name: exporter-darwin-arm64
path: safetyculture-exporter-darwin-arm64.zip
release:
runs-on: ubuntu-latest
needs: package
steps:
- name: Download package windows amd64
uses: actions/download-artifact@v2
with:
name: exporter-windows-amd64
- name: Download package darwin amd64
uses: actions/download-artifact@v2
with:
name: exporter-darwin-amd64
- name: Download package darwin arm64
uses: actions/download-artifact@v2
with:
name: exporter-darwin-arm64
- name: Download package linux amd64
uses: actions/download-artifact@v2
with:
name: exporter-linux-amd64
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
artifacts: "safetyculture-exporter-windows-x86_64.zip,safetyculture-exporter-darwin-arm64.zip,safetyculture-exporter-darwin-amd64.zip,safetyculture-exporter-linux-amd64.zip"
allowUpdates: true
prerelease: true
draft: true
makeLatest: false