Skip to content

Commit ecf0c9d

Browse files
committed
wip
0 parents  commit ecf0c9d

File tree

5 files changed

+137
-0
lines changed

5 files changed

+137
-0
lines changed

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: release
2+
3+
on:
4+
pull_request:
5+
push:
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
12+
jobs:
13+
goreleaser:
14+
runs-on: macos-latest
15+
env:
16+
MACOS_SIGN_P12: ${{ secrets.MACOS_SIGN_P12 }} # base64 .p12 key
17+
MACOS_SIGN_PASSWORD: ${{ secrets.MACOS_SIGN_PASSWORD }} # password to open the .p12 file
18+
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} # a password for our temporary keychain
19+
MACOS_NOTARY_KEYCHAIN_PROFILE: ${{ secrets.MACOS_NOTARY_KEYCHAIN_PROFILE }} # the profile name to create and use for notarization
20+
MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }} # base64 .p8 key
21+
MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }} # the .p8 key ID
22+
MACOS_NOTARY_ISSUER_ID: ${{ secrets.MACOS_NOTARY_ISSUER_ID }} # the issuer UUID
23+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
24+
steps:
25+
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
26+
run: echo "flags=--snapshot" >> $GITHUB_ENV
27+
- uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
- uses: actions/setup-go@v5
31+
with:
32+
go-version: stable
33+
- name: 'setup-keychain'
34+
run: |
35+
# create variables
36+
CERTIFICATE_PATH=$RUNNER_TEMP/goreleaser.p12
37+
KEY_PATH=$RUNNER_TEMP/goreleaser.p8
38+
KEYCHAIN_PATH=$RUNNER_TEMP/goreleaser.keychain-db
39+
40+
# import certificate and key from secrets
41+
echo -n "$MACOS_SIGN_P12" | base64 --decode -o $CERTIFICATE_PATH
42+
echo -n "$MACOS_NOTARY_KEY" | base64 --decode -o $KEY_PATH
43+
44+
# create temporary keychain
45+
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
46+
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
47+
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
48+
49+
# import certificate to keychain
50+
security import $CERTIFICATE_PATH -P "$MACOS_SIGN_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
51+
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
52+
security list-keychain -d user -s $KEYCHAIN_PATH
53+
54+
# create notary profile
55+
xcrun notarytool store-credentials $MACOS_NOTARY_KEYCHAIN_PROFILE \
56+
--key $KEY_PATH \
57+
--key-id $MACOS_NOTARY_KEY_ID \
58+
--issuer $MACOS_NOTARY_ISSUER_ID \
59+
--keychain $KEYCHAIN_PATH
60+
61+
# export the keychain path
62+
echo "KEYCHAIN_PATH=$KEYCHAIN_PATH" >>$GITHUB_ENV
63+
- uses: goreleaser/goreleaser-action@v6
64+
with:
65+
distribution: goreleaser-pro
66+
version: "nightly"
67+
args: release --clean ${{ env.flags }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Added by goreleaser init:
2+
dist/

.goreleaser.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
4+
# The lines below are called `modelines`. See `:help modeline`
5+
# Feel free to remove those if you don't want/need to use them.
6+
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
7+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
8+
9+
version: 2
10+
pro: true
11+
12+
project_name: example
13+
before:
14+
hooks:
15+
- go mod tidy
16+
17+
builds:
18+
- env:
19+
- CGO_ENABLED=0
20+
goos:
21+
- linux
22+
- darwin
23+
24+
universal_binaries:
25+
- name_template: example
26+
replace: true
27+
28+
app_bundles:
29+
- icon: icon.icns
30+
bundle: com.goreleaser.example
31+
32+
dmg:
33+
- name: Example
34+
replace: true
35+
36+
notarize:
37+
macos_native:
38+
- enabled: '{{ isEnvSet "MACOS_SIGN_P12" }}'
39+
sign:
40+
identity: "Developer ID Application: Carlos Becker"
41+
keychain: "{{ .Env.KEYCHAIN_PATH }}"
42+
notarize:
43+
wait: true
44+
profile_name: "{{ .Env.MACOS_NOTARY_KEYCHAIN_PROFILE }}"
45+
46+
changelog:
47+
sort: asc
48+
filters:
49+
exclude:
50+
- "^docs:"
51+
- "^test:"
52+
53+
release:
54+
footer: >-
55+
56+
---
57+
58+
Released by [GoReleaser](https://github.com/goreleaser/goreleaser).

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/goreleaser/example-notarized-apps
2+
3+
go 1.22.12

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
fmt.Println("Hello World")
7+
}

0 commit comments

Comments
 (0)