Skip to content

Commit

Permalink
Merge pull request #87 from multani/github-actions
Browse files Browse the repository at this point in the history
Test and release using GitHub Actions
  • Loading branch information
carlpett authored May 13, 2022
2 parents 375a6b4 + 0dc12fa commit 504bfd6
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 46 deletions.
38 changes: 0 additions & 38 deletions .circleci/config.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
push:
tags:
- v*

env:
GO_VERSION: '1.18'

# Request permissions to write (edit, create) new releases
permissions:
contents: write

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Setup golang ${{ env.GO_VERSION }}
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Checkout
uses: actions/checkout@v3

- name: Build
run: go build -v .

- name: Import test GPG key
run: gpg --import test/testing-key.pgp

- name: Test
run: make test

- name: Crossbuild
run: make crossbuild

- name: Release
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Tests

on:
pull_request:
push:

env:
GO_VERSION: '1.18'

jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Setup golang ${{ env.GO_VERSION }}
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Checkout
uses: actions/checkout@v3

- name: Build
run: go build -v .

- name: Import test GPG key
run: gpg --import test/testing-key.pgp

- name: Test
run: make test

- name: Crossbuild
run: make crossbuild
12 changes: 4 additions & 8 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,16 @@ $(GOPATH)/bin/gox:
# Need to disable modules for this to not pollute go.mod
@GO111MODULE=off go get -u github.com/mitchellh/gox

release: crossbuild bin/hub
# This uses the `hub` tool, which is preinstalled on GitHub Actions runners.
release: crossbuild
@echo ">> uploading release $(VERSION)"
mkdir -p releases
set -e; for OSARCH in $(OSARCH_COMBOS); do \
zip -j releases/terraform-provider-sops_$(RELEASE)_$$OSARCH.zip binaries/$(VERSION)/$$OSARCH/terraform-provider-sops_* > /dev/null; \
./bin/hub release edit -m "" -a "releases/terraform-provider-sops_$(RELEASE)_$$OSARCH.zip#terraform-provider-sops_$(RELEASE)_$$OSARCH.zip" $(VERSION); \
hub release edit -m "" -a "releases/terraform-provider-sops_$(RELEASE)_$$OSARCH.zip#terraform-provider-sops_$(RELEASE)_$$OSARCH.zip" $(VERSION); \
done
@echo ">>> generating sha256sums:"
cd releases; sha256sum *.zip | tee terraform-provider-sops_$(RELEASE)_SHA256SUMS
./bin/hub release edit -m "" -a "releases/terraform-provider-sops_$(RELEASE)_SHA256SUMS#terraform-provider-sops_$(RELEASE)_SHA256SUMS" $(VERSION)

bin/hub:
@mkdir -p bin
curl -sL 'https://github.com/github/hub/releases/download/v2.14.1/hub-linux-amd64-2.14.1.tgz' | \
tar -xzf - --strip-components 2 -C bin --wildcards '*/bin/hub'
hub release edit -m "" -a "releases/terraform-provider-sops_$(RELEASE)_SHA256SUMS#terraform-provider-sops_$(RELEASE)_SHA256SUMS" $(VERSION)

.PHONY: all style vet test build crossbuild release

0 comments on commit 504bfd6

Please sign in to comment.