Skip to content

Merge pull request #65 from Labbs/migration-to-labbs-org #20

Merge pull request #65 from Labbs/migration-to-labbs-org

Merge pull request #65 from Labbs/migration-to-labbs-org #20

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
env:
REGISTRY: ghcr.io
APP_NAME: ${{ github.repository }}
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
# go-version: 1.19
go-version-file: go.mod
# The builtin cache feature ensures that installing golangci-lint
# is consistently fast.
cache: true
cache-dependency-path: go.sum
- uses: nowsprinting/check-version-format-action@v3
if: github.event_name != 'pull_request'
id: version
with:
prefix: 'v'
- name: Build app
run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-X 'main.version=${{ steps.version.outputs.full }}'" -o bin/${{ env.APP_NAME }} .
- name: Generate MD5
run: md5sum bin/${{ env.APP_NAME }} > bin/${{ env.APP_NAME }}.md5
- name: Push to release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: true
files: |
bin/${{ env.APP_NAME }}
bin/${{ env.APP_NAME }}.md5
prerelease: ${{ steps.version.outputs.prerelease }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.APP_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}