Skip to content

Commit

Permalink
feat(ci): arm builds, push multiple registries
Browse files Browse the repository at this point in the history
Release-As: 0.13.0
  • Loading branch information
sentriz committed May 8, 2021
1 parent c2c7eb2 commit 0622672
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 109 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/go.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/image.yml

This file was deleted.

63 changes: 49 additions & 14 deletions .github/workflows/nightly-release.yaml
Expand Up @@ -4,24 +4,59 @@ on:
- cron: '0 0 * * *'
workflow_dispatch: {}
jobs:
test:
name: Lint and test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y -qq build-essential git sqlite libtag1-dev ffmpeg libasound-dev
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
skip-go-installation: true
- name: Test
run: go test ./...
build-release:
name: Build and release Docker image
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Update version.go
run: |
_version=v$(cat version.txt)
sed -Ei "s/VERSION = \"v0.0.0\"/VERSION = \"${_version}-nightly\"/g" version/version.go
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
version: latest
driver-opts: image=moby/buildkit:master
- name: Login into DockerHub
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Login into GitHub Container Registry
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Build Docker image
run: |
docker build \
-t "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}" \
-t "ghcr.io/${GITHUB_REPOSITORY}:nightly" .
- name: Release Docker image
run: |
docker push "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA:0:7}"
docker push "ghcr.io/${GITHUB_REPOSITORY}:nightly"
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and Push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ github.sha }}
ghcr.io/${{ github.repository }}:nightly
${{ github.repository }}:${{ github.sha }}
${{ github.repository }}:nightly
52 changes: 33 additions & 19 deletions .github/workflows/release.yaml
Expand Up @@ -5,41 +5,55 @@ on:
- master
jobs:
release-please:
name: Run release-please
name: Run Release Please
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup release please
- name: Setup Release Please
uses: google-github-actions/release-please-action@v2
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.CR_PAT }}
release-type: simple
changelog-path: CHANGELOG.md
package-name: gonic
build-tag-publish:
build-release:
name: Build, tag, and publish Docker image
if: ${{ needs.release-please.outputs.release_created }}
needs: release-please
runs-on: ubuntu-latest
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Update version.go
run: sed -Ei 's/VERSION = "v0.0.0"/VERSION = "${{ needs.release-please.outputs.tag_name }}"/g' version/version.go
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
version: latest
driver-opts: image=moby/buildkit:master
- name: Login into DockerHub
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Login into GitHub Container Registry
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Build Docker image
if: ${{ needs.release-please.outputs.release_created }}
run: |
docker build \
-t "ghcr.io/${GITHUB_REPOSITORY}:${{ needs.release-please.outputs.tag_name }}" \
-t "ghcr.io/${GITHUB_REPOSITORY}:latest" .
- name: Release Docker image
run: |
docker push "ghcr.io/${GITHUB_REPOSITORY}:${{ needs.release-please.outputs.tag_name }}"
docker push "ghcr.io/${GITHUB_REPOSITORY}:latest"
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and Push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ needs.release-please.outputs.tag_name }}
ghcr.io/${{ github.repository }}:latest
${{ github.repository }}:${{ needs.release-please.outputs.tag_name }}
${{ github.repository }}:latest
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,29 @@
name: Lint and test
on:
push:
branches:
- master
- develop
pull_request:
jobs:
test:
name: Lint and test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y -qq build-essential git sqlite libtag1-dev ffmpeg libasound-dev
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
skip-go-installation: true
- name: Test
run: go test ./...
1 change: 1 addition & 0 deletions Dockerfile
Expand Up @@ -15,6 +15,7 @@ COPY . .
RUN GOOS=linux go build -o gonic cmd/gonic/gonic.go

FROM alpine:3.13.1
LABEL org.opencontainers.image.source https://github.com/sentriz/gonic
RUN apk add -U --no-cache \
ffmpeg \
ca-certificates \
Expand Down

0 comments on commit 0622672

Please sign in to comment.