forked from billiford/arcade
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from homedepot/release-to-ghcr
Switch Release to GH Container Registry
- Loading branch information
Showing
4 changed files
with
128 additions
and
71 deletions.
There are no files selected for viewing
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
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 |
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
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 }} |
This file was deleted.
Oops, something went wrong.
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
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 |