Added dockerhub link #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'v*' | |
pull_request: | |
paths-ignore: | |
- 'README.md' | |
- 'docs/**' | |
- 'LICENSE' | |
- 'getting_started.md' | |
env: | |
go-version: '1.21.5' | |
cmd-name: 'greenmask' | |
docker-registry: greenmask/greenmask | |
jobs: | |
unit-tests: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.go-version }} | |
- name: Echo Go version | |
run: go version | |
- name: Run tests | |
run: make tests | |
integration-tests: | |
runs-on: ubuntu-22.04 | |
needs: | |
- unit-tests | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Run integration tests | |
run: | | |
docker-compose -f docker-compose-integration.yml -p greenmask up \ | |
--renew-anon-volumes --force-recreate --build --exit-code-from greenmask \ | |
--abort-on-container-exit greenmask | |
binaries: | |
runs-on: ubuntu-22.04 | |
needs: | |
- unit-tests | |
- integration-tests | |
strategy: | |
matrix: | |
platforms: | |
- 'windows/arm64' | |
- 'windows/amd64' | |
- 'darwin/amd64' | |
- 'darwin/arm64' | |
- 'linux/amd64' | |
- 'linux/arm64' | |
- 'linux/arm/v6' | |
- 'linux/arm/v7' | |
- 'linux/ppc64le' | |
- 'linux/riscv64' | |
- 'linux/s390x' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.go-version }} | |
- name: Echo Go version | |
run: go version | |
- name: Build with different arch | |
run: | | |
export GOOS=$(echo ${{ matrix.platforms }} | cut -d '/' -f 1) | |
export GOARCH=$(echo ${{ matrix.platforms }} | cut -d '/' -f 2) | |
export GOARM=$(echo ${{ matrix.platforms }} | cut -d '/' -f 3 | cut -d 'v' -f 2) | |
if [[ "x$GOOS" == "xwindows" ]]; then | |
make build CMD_NAME="builds/${{ env.cmd-name }}_${GOOS}_${GOARCH}.exe" | |
elif [[ "x$GOARM" != "x" ]]; then | |
make build CMD_NAME="builds/${{ env.cmd-name }}_${GOOS}_${GOARCH}v${GOARM}" | |
else | |
make build CMD_NAME="builds/${{ env.cmd-name }}_${GOOS}_${GOARCH}" | |
fi | |
- name: Create checksums | |
if: startsWith(github.ref, 'refs/tags/v') | |
working-directory: builds | |
run: | | |
find . -type f -exec shasum -a 256 -b {} + | sed 's# \*\./# *#' | while read sum file; do echo "$sum $file" > "${file#\*}".sha256; done | |
- name: List artifacts | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: tree -nh builds | |
- name: GitHub Release | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
draft: true | |
files: builds/* | |
build-docker-images-and-push: | |
runs-on: ubuntu-22.04 | |
needs: | |
- binaries | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Get Git tag | |
id: git_tag | |
run: echo "TAG=$(git tag --points-at HEAD)" >> $GITHUB_ENV | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
file: docker/greenmask/Dockerfile | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ env.docker-registry }}:${{ env.TAG }},${{ env.docker-registry }}:latest |