Skip to content

Commit

Permalink
update release action to build universal binary (#96)
Browse files Browse the repository at this point in the history
* update release action to build universal binary

* add step to build on macos on PR creation action

* add matrix to gh action
  • Loading branch information
blacs30 committed Aug 18, 2021
1 parent b34ffef commit 0af7c8e
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ jobs:
# uses: creekorful/goreportcard-action@v1.0

build:
name: Build
runs-on: ubuntu-20.04
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [lint, test]
strategy:
matrix:
os: [macos-latest, ubuntu-20.04]
steps:
- name: Granting private modules access
run: |
Expand All @@ -92,3 +95,8 @@ jobs:

- name: Build
run: make build

- name: Create universal binary
if: ${{ matrix.os == 'macos-latest' }}
run: |
make universal-binary
12 changes: 10 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ jobs:


build:
name: Build
runs-on: ubuntu-20.04
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [lint, test]
strategy:
matrix:
os: [macos-latest, ubuntu-20.04]
steps:
- name: Granting private modules access
run: |
Expand All @@ -89,3 +92,8 @@ jobs:

- name: Build
run: make build

- name: Create universal binary
if: ${{ matrix.os == 'macos-latest' }}
run: |
make universal-binary
40 changes: 38 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
- '*'

jobs:
release:
runs-on: ubuntu-20.04
build-release:
runs-on: macos-latest
steps:
- name: Granting private modules access
run: |
Expand All @@ -34,6 +34,42 @@ jobs:
run: |
make build
- name: Create universal binary
run: |
make universal-binary
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: universal-binary
path: workflow/bitwarden-alfred-workflow

release:
needs: build-release
runs-on: ubuntu-20.04
steps:
- name: Granting private modules access
run: |
git config --global url."https://${{ secrets.GO_MODULES_TOKEN }}:x-oauth-basic@github.com/blacs30".insteadOf "https://github.com/blacs30"
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.16

- name: Check out code
uses: actions/checkout@v2

- name: Dowload artifacts
uses: actions/download-artifact@v2
with:
name: universal-binary
path: download

- run: |
test -f download/bitwarden-alfred-workflow && cp download/bitwarden-alfred-workflow workflow/bitwarden-alfred-workflow
chmod +x workflow/bitwarden-alfred-workflow
- name: Copy run dependencies
run: |
make copy-build-assets
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ workflow/README.html
workflow/List Filter Images
workflow/bw_cache_update.sh
workflow/bw_auto_lock.sh
workflow/fix_flags.sh
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ build: dep ## Build the binary file
@CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o workflow/$(PROJECT_NAME)-amd64
@CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o workflow/$(PROJECT_NAME)-arm64

universal-binary:
@lipo -create -output workflow/bitwarden-alfred-workflow workflow/bitwarden-alfred-workflow-amd64 workflow/bitwarden-alfred-workflow-arm64

clean: ## Remove previous build
@rm -f workflow/$(PROJECT_NAME)

Expand All @@ -42,6 +45,8 @@ copy-build-assets:
@cp -r assets ./workflow
@cp bw_cache_update.sh ./workflow
@cp bw_auto_lock.sh ./workflow
@cp fix_flags.sh ./workflow
@chmod +x ./workflow/*.sh
@go get github.com/pschlump/markdown-cli
@markdown-cli -i README.md -o workflow/README.html

Expand Down
2 changes: 1 addition & 1 deletion bitwarden.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func runLogin() {
if err != nil {
wf.FatalError(err)
}
// set the password from the returned slice
// set the token from the returned result
token := ""
if len(tokenReturn) > 0 {
token = tokenReturn[0]
Expand Down

0 comments on commit 0af7c8e

Please sign in to comment.