Skip to content

Commit

Permalink
added code to build, sign and notarize via github action
Browse files Browse the repository at this point in the history
  • Loading branch information
kencochrane committed Aug 1, 2020
1 parent a22067e commit 93f8835
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: kencochrane
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: build and sign binaries

on:
push:
tags:
- '*'

jobs:
build:
name: Build the binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: |
./build.sh
- name: upload binary artifacts
uses: actions/upload-artifact@v2
with:
name: binaries
path: release/
release:
needs: build
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Download-Binaries
uses: actions/download-artifact@v2
with:
name: binaries
path: release/

- name: Display structure of downloaded files
run: ls -R

- name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v1
with:
# The certificates in a PKCS12 file encoded as a base64 string
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
# The password used to import the PKCS12 file.
p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}

- name: Install gon via HomeBrew for code signing and app notarization
run: |
brew tap mitchellh/gon
brew install mitchellh/gon/gon
- name: Sign the mac binaries with Gon
env:
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
run: |
./sign.sh
- name: Archive Mac DiskImage distributable
uses: actions/upload-artifact@v2
with:
name: Released-Mac-DiskImage
path: release/darwin/
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
vendor/

# release directory, this has binaries, don't commit those.
release/
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
BINARY := hello-github

.PHONY: windows
windows:
mkdir -p release/windows/
GOOS=windows GOARCH=amd64 go build -o release/windows/$(BINARY).exe

.PHONY: linux
linux:
mkdir -p release/linux/
GOOS=linux GOARCH=amd64 go build -o release/linux/$(BINARY)

.PHONY: darwin
darwin:
mkdir -p release/darwin/
GOOS=darwin GOARCH=amd64 go build -o release/darwin/$(BINARY)

.PHONY: build
build: windows linux darwin

.PHONY: sign
sign:
# sign
gon -log-level=debug -log-json ./gon.json

.PHONY: release
release: sign
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# golang-github-action-sign-macos
Example repo showing how to use Github Actions to sign a golang binary for macos
Example repo showing how to use Github Actions to sign and notarize a Golang binary for MacOS.


See blog post for more information.
- Add link to https://www.kencochrane.com once published
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker run --rm -v `pwd`:/usr/src/myapp -v `pwd`/vendor:/go/src -w /usr/src/myapp golang:1.14 /usr/src/myapp/build_app.sh
4 changes: 4 additions & 0 deletions build_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# build all three versions windows, linux, mac, in parallel
make build -j3
17 changes: 17 additions & 0 deletions gon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"source" : ["./release/darwin/hello-github"],
"bundle_id" : "com.kencochrane.hello-github",
"apple_id": {
"password": "@env:AC_PASSWORD"
},
"sign" :{
"application_identity" : "4194587FE60D93D416CF3F4669FF913C7BBA4271"
},
"dmg" :{
"output_path": "./release/darwin/hello-github.dmg",
"volume_name": "hello-github"
},
"zip" :{
"output_path" : "./release/darwin/hello-github.zip"
}
}
7 changes: 7 additions & 0 deletions hello-github.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Hello GitHub!")
}
4 changes: 4 additions & 0 deletions sign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# sign the mac version
make sign

0 comments on commit 93f8835

Please sign in to comment.