Skip to content

Commit

Permalink
Transfer Circle CI Automation to Github Actions (#335)
Browse files Browse the repository at this point in the history
* initial set up of github actions yml

* change run on to ubuntu latest

* roll back to our runners

* add test + clean step

* remove working directory

* add make distributables step

* add release workflow

Co-authored-by: Enrico Alvarenga <[email protected]>

* define two tag patterns to trigger chamber pkg release

* remove circleci references

* remove extra space in new line

* change secrets' names

* test docker hub login on build workflow

* cleanup build workflow

* fix default branch

Co-authored-by: Enrico Alvarenga <[email protected]>
Co-authored-by: Enrico Alvarenga <[email protected]>
  • Loading branch information
3 people authored Apr 8, 2022
1 parent f989b21 commit 3353ad1
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 160 deletions.
156 changes: 0 additions & 156 deletions .circleci/config.yml

This file was deleted.

1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.git
.github
.circleci
93 changes: 93 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

name: Test & Build
on:
push:
branches:
- master

pull_request:

jobs:
install-go-modules:
strategy:
matrix:
go: ['1.16.x', '1.15.x']

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Test install Go modules for v${{ matrix.go }}
run: go get -v . && chamber version

test:
strategy:
matrix:
go: ['1.16.x']
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Test
run: make test

- name: Check modules are tidy and checked in
run: |
export GO111MODULE=on
go mod tidy
if [ "$(git status --porcelain)" != "" ]; then
echo "git tree is dirty after tidying modules"
echo "ensure go.mod and go.sum are tidy"
git status
exit 1
fi
dist:
strategy:
matrix:
go: ['1.16.x']
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Install nfpm, rpmbuild
run: sudo make -f Makefile.tools nfpm-debian rpmbuild-debian

- name: Make distributables
run: make -f Makefile.release dist
- uses: actions/upload-artifact@v3
with:
name: dist
path: 'dist/*'

test-dockerhub-login:
runs-on: ubuntu-latest
needs: dist

steps:
- uses: actions/checkout@v2

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWD }}
93 changes: 93 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]-[a-zA-Z0-9]+'

jobs:
dist:
strategy:
matrix:
go: ['1.16.x']
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Install nfpm, rpmbuild
run: sudo make -f Makefile.tools nfpm-debian rpmbuild-debian

- name: Make distributables
run: make -f Makefile.release dist
- uses: actions/upload-artifact@v3
with:
name: dist
path: 'dist/*'

publish-github:
strategy:
matrix:
go: ['1.16.x']
runs-on: ubuntu-latest
needs: dist

steps:
- uses: actions/checkout@v2

- uses: actions/download-artifact@v3
with:
name: dist
path: 'dist/*'

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Install tools
run: make -f Makefile.tools github-release

- name: Release
run: make -f Makefile.release publish-github

publish-dockerhub:
strategy:
matrix:
go: ['1.16.x']
runs-on: ubuntu-latest
needs: dist

steps:
- uses: actions/checkout@v2

- uses: actions/download-artifact@v3
with:
name: dist
path: 'dist/*'

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWD }}

- name: Release
run:
make -f Makefile.release publish-dockerhub
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Goals:
# - user can build binaries on their system without having to install special tools
# - user can fork the canonical repo and expect to be able to run CircleCI checks
# - user can fork the canonical repo and expect to be able to run Github Actions checks
#
# This makefile is meant for humans

Expand Down
2 changes: 1 addition & 1 deletion Makefile.release
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Goals:
# - Linux releases can be published to Github automatically by CircleCI
# - Linux releases can be published to Github automatically by Github Actions
#
# This Makefile is meant for machines

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,5 @@ This feature is experimental, and not currently meant for production work.
## Releasing

To cut a new release, just push a tag named `v<semver>` where `<semver>` is a
valid semver version. This tag will be used by Circle to automatically publish
valid semver version. This tag will be used by Github Actions to automatically publish
a github release.

0 comments on commit 3353ad1

Please sign in to comment.