-
Notifications
You must be signed in to change notification settings - Fork 8
138 lines (123 loc) · 4.73 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
name: Build
on:
push:
workflow_call:
inputs:
tag_name:
type: string
draft:
type: string
prerelease:
type: string
generate_release_notes:
type: string
jobs:
build:
name: build
# The build job has a matrix strategy, which means it will run multiple times with different combinations of the os, arch, and target variables.
strategy:
fail-fast: false
matrix:
include:
# The first combination is Ubuntu running on an AMD64 processor, building for Windows.
- os: ubuntu-latest
arch: amd64
target: windows
ext: .exe
cc: x86_64-w64-mingw32-gcc
ldflags: "-H windowsgui"
# The second combination is Ubuntu running on an AMD64 processor, building for Linux.
- os: ubuntu-22.04
arch: amd64
target: linux
# The third combination is macOS running on an AMD64 processor, building for Darwin (macOS).
- os: macos-13
arch: amd64
target: darwin
cgo_ldflags: "-framework UniformTypeIdentifiers -F /System/Library/Frameworks"
# The fourth combination is macOS running on an ARM64 processor, building for Darwin (macOS).
- os: macos-13
arch: arm64
target: darwin
cgo_ldflags: "-framework UniformTypeIdentifiers -F /System/Library/Frameworks"
# The build job runs on the specified operating system.
runs-on: ${{ matrix.os }}
env:
TARGET_NAME: wallet-plugin_${{ matrix.target }}-${{ matrix.arch }}
GOOS: ${{ matrix.target }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 1
CC: ${{ matrix.cc }}
CGO_LDFLAGS: ${{ matrix.cgo_ldflags }}
TAG: ${{ inputs.tag_name }}
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install
with:
os: ${{ matrix.os }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build binary for ${{ matrix.target }} ${{ matrix.arch }}
if: matrix.target != 'darwin'
shell: bash
run: |
TAGS="desktop,production"
if [ "${{ matrix.target }}" == "linux" ]; then
TAGS="$TAGS,webkit2_41"
fi
go build -tags "$TAGS" -ldflags "-w -s ${{ matrix.ldflags }}" -o $TARGET_NAME${{ matrix.ext }} main.go
- name: Build binary for MacOS ${{ matrix.arch }}
if: matrix.target == 'darwin'
shell: bash
run: |
task build
chmod +x build/bin/*/Contents/MacOS/*
ditto -c -k build/bin/wallet-plugin.app wallet-plugin.app.zip
- name: Sign Windows binary
if: matrix.target == 'windows'
uses: massalabs/station/.github/actions/sign-file@3dac9091bcbe6db4facec2c0f30292f56c11098e
with:
file: $TARGET_NAME${{ matrix.ext }}
GCP_PEM_KEY: ${{ vars.GCP_PEM_KEY }}
GCP_KEYSTORE_ID: ${{ vars.GCP_KEYSTORE_ID }}
GCP_KEY_ALIAS: ${{ vars.GCP_KEY_ALIAS }}
GCP_WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
GCP_SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.TARGET_NAME }}
path: |
wallet-plugin*
wallet.svg
manifest.json
- name: Zip binary
if: ${{ (matrix.target != 'darwin') && (inputs.tag_name != '') }}
run: zip $TARGET_NAME.zip $TARGET_NAME${{ matrix.ext }} wallet.svg manifest.json
- name: Zip binary for darwin
if: ${{ (matrix.target == 'darwin') && (inputs.tag_name != '') }}
run: zip $TARGET_NAME.zip wallet-plugin.app.zip wallet.svg manifest.json
- name: Create release and upload binaries
if: ${{ inputs.tag_name != '' }}
uses: softprops/action-gh-release@v1
with:
target_commitish: ${{ github.sha }}
tag_name: ${{ inputs.tag_name }}
draft: ${{ inputs.draft }}
prerelease: ${{ inputs.prerelease }}
generate_release_notes: ${{ inputs.generate_release_notes }}
files: ${{ env.TARGET_NAME }}.zip
- name: Configure AWS credentials
if: ${{ inputs.tag_name != '' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-west-3
aws-access-key-id: ${{ secrets.MS_S3_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.MS_S3_SECRET_ACCESS_KEY }}
- name: s3 Upload
if: ${{ inputs.tag_name != '' }}
env:
AWS3: ${{ vars.MS_S3_BUCKET }}
run: aws s3 cp $TARGET_NAME.zip s3://${AWS3}/plugins/wallet/${TAG}/${TARGET_NAME}.zip