-
-
Notifications
You must be signed in to change notification settings - Fork 159
149 lines (143 loc) · 5.67 KB
/
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
name: Release
on:
push:
branches: [main]
tags:
- "v*.*.*"
paths:
- ".github/workflows/release.yml"
- ".goreleaser.yaml"
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
concurrency:
group: release-${{ github.event_name }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: write
discussions: write
strategy:
matrix:
include:
- os: macos-latest
cache-subdir: darwin
- os: ubuntu-22.04
cache-subdir: linux
_ids: --id linux-x64-wayland --id linux-x64-x11
- os: ubuntu-22.04-arm
cache-subdir: linux
_ids: --id linux-arm64-wayland --id linux-arm64-x11
- os: windows-latest
cache-subdir: windows
fail-fast: false
outputs:
cache-hit: ${{ steps.cache-check.outputs.cache-hit }}
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
MACOS_SIGN_P12: ${{ secrets.MACOS_SIGN_P12 }}
MACOS_SIGN_PASSWORD: ${{ secrets.MACOS_SIGN_PASSWORD }}
MACOS_NOTARY_ISSUER_ID: ${{ secrets.MACOS_NOTARY_ISSUER_ID }}
MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }}
MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
MACOS_NOTARY_KEYCHAIN_PROFILE: ${{ secrets.MACOS_NOTARY_KEYCHAIN_PROFILE }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
path: dist/${{ matrix.cache-subdir }}
key: goreleaser-${{ matrix.os }}-${{ github.sha }}
enableCrossOsArchive: ${{ matrix.os == 'windows-latest' }}
lookup-only: true
fail-on-cache-miss: false
id: cache-check
- if: matrix.os == 'macos-latest'
run: rustup target add x86_64-apple-darwin
- if: matrix.os == 'windows-latest'
run: rustup target add aarch64-pc-windows-msvc
- if: matrix.os == 'macos-latest'
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/goreleaser.p12
KEY_PATH=$RUNNER_TEMP/goreleaser.p8
KEYCHAIN_PATH=$RUNNER_TEMP/goreleaser.keychain-db
# import certificate and key from secrets
echo -n "$MACOS_SIGN_P12" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$MACOS_NOTARY_KEY" | base64 --decode -o $KEY_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$MACOS_SIGN_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# create notary profile
xcrun notarytool store-credentials "$MACOS_NOTARY_KEYCHAIN_PROFILE" \
--key "$KEY_PATH" \
--key-id "$MACOS_NOTARY_KEY_ID" \
--issuer "$MACOS_NOTARY_ISSUER_ID" \
--keychain $KEYCHAIN_PATH
# export the keychain path
echo "KEYCHAIN_PATH=$KEYCHAIN_PATH" >>$GITHUB_ENV
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && steps.cache-check.outputs.cache-hit != 'true'
uses: goreleaser/[email protected]
with:
distribution: goreleaser-pro
version: nightly
args: release --clean --split ${{ matrix._ids }}
- if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v'))) && steps.cache-check.outputs.cache-hit != 'true'
uses: goreleaser/[email protected]
with:
distribution: goreleaser-pro
version: nightly
args: release --clean --split ${{ matrix._ids }} --nightly --skip=winget
release:
# skip if cache exists for same commit, since we probably already released
if: needs.build.outputs.cache-hit != 'true'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
key: goreleaser-macos-latest-${{ github.sha }}
path: dist/darwin
fail-on-cache-miss: true
- uses: actions/cache@v4
with:
key: goreleaser-windows-latest-${{ github.sha }}
path: dist/windows
fail-on-cache-miss: true
- uses: actions/cache@v4
with:
key: goreleaser-ubuntu-22.04-arm-${{ github.sha }}
path: dist/linux
fail-on-cache-miss: true
- name: workaround to avoid conflicts b/w linux x64/arm64 caches
run: |
# rename linux to linux-arm64, to avoid cache restore conflicts
mv dist/linux dist/linux-arm64
# update paths in artifacts.json (dist/linux -> dist/linux-arm64)
sed -i 's/dist\/linux/dist\/linux-arm64/g' dist/linux-arm64/artifacts.json
- uses: actions/cache@v4
with:
key: goreleaser-ubuntu-22.04-${{ github.sha }}
path: dist/linux
fail-on-cache-miss: true
- uses: goreleaser/[email protected]
with:
distribution: goreleaser-pro
version: nightly
args: continue --merge
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}