Skip to content

Commit

Permalink
Merge pull request #18 from homedepot/release-to-ghcr
Browse files Browse the repository at this point in the history
Switch Release to GH Container Registry
  • Loading branch information
ryanjohnsontv authored Mar 15, 2024
2 parents 542924f + b2c0ba8 commit 3750d1e
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 71 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build

on:
workflow_dispatch:
push:
branches: [master]
pull_request:
branches: [master]
workflow_call:

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
cache: false

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
go mod tidy
- name: Verify dependencies
run: go mod verify

- name: lint
uses: golangci/golangci-lint-action@v4
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.55
args: --skip-files .*_test.go --enable wsl --enable misspell --out-format=colored-line-number --timeout 180s

- name: Build
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v cmd/arcade/arcade.go

- name: Test
run: go test -v ./...

- uses: actions/upload-artifact@v3
with:
name: build
path: arcade
67 changes: 67 additions & 0 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Docker
on:
workflow_call:

env:
CONTAINER_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/download-artifact@v3
with:
name: build

- name: Add executable permissions
run: |
chmod +x arcade
- name: Set release info
run: |
event_type=${{ github.event.action }}
release_version=$(echo ${{ github.ref_name }} | sed 's/v//g' | sed 's/+/-/g')
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
if [[ $event_type == "released" ]]; then
echo "TAGS=${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:$release_version,${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_ENV
else
echo "TAGS=${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:$release_version" >> $GITHUB_ENV
fi
- name: Login
uses: docker/login-action@v3
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Set up docker context for buildx
id: buildx-context
run: |
docker context create builders
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2
with:
endpoint: builders
driver-opts: |
image=moby/buildkit:master
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.TAGS }}
labels: |
org.opencontainers.image.source=https://github.com/${{ env.IMAGE_NAME }}
org.opencontainers.image.version=${{ env.RELEASE_VERSION }}
44 changes: 0 additions & 44 deletions .github/workflows/go.yml

This file was deleted.

35 changes: 8 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
name: Release
on:
workflow_dispatch:
inputs:
version:
type: string
description: version to tag image

jobs:
on:
release:
runs-on: ubuntu-latest
env:
VERSION: ${{ github.event.inputs.version }}
steps:
- name: Setup - checkout
uses: actions/checkout@v4
types: [prereleased, released]

- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ^1.21
id: go

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
jobs:
build:
uses: ./.github/workflows/build.yml

- name: docker
shell: bash
run: docker/docker-build.sh -v ${VERSION}
docker:
needs: build
uses: ./.github/workflows/docker-push.yml

0 comments on commit 3750d1e

Please sign in to comment.