Skip to content

Build Docker Image

Build Docker Image #83

Workflow file for this run

name: Build Docker Image
on:
schedule:
- cron: '0 0 * * MON'
workflow_dispatch:
push:
tags:
- 'v*'
jobs:
release:
name: Release GitHub tag
runs-on: 'ubuntu-latest'
permissions:
contents: write
outputs:
new_tag: ${{ steps.tag_version.outputs.new_tag }}
changelog: ${{ steps.tag_version.outputs.changelog }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
default_bump: minor
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Release with Notes
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
push:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: [ release ]
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Login to GitHub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_REGISTRY_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push to GitHub
uses: docker/build-push-action@v6
with:
context: ./
file: ./Dockerfile
push: true
tags: ghcr.io/omegion/ssh-manager:latest,ghcr.io/omegion/ssh-manager:${{ needs.release.outputs.new_tag }}
platforms: linux/amd64,linux/arm64
build-args: VERSION=${{ needs.release.outputs.new_tag }}
build:
name: Build Binary
runs-on: 'ubuntu-latest'
needs: [ release ]
strategy:
matrix:
# List of GOOS and GOARCH pairs from `go tool dist list`
goosarch:
- 'darwin/amd64'
- 'darwin/arm64'
- 'linux/amd64'
- 'linux/arm64'
- 'windows/amd64'
- 'windows/arm64'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Get OS and arch info
run: |
GOOSARCH=${{matrix.goosarch}}
GOOS=${GOOSARCH%/*}
GOARCH=${GOOSARCH#*/}
BINARY_NAME=ssh-manager-$GOOS-$GOARCH
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
echo "GOOS=$GOOS" >> $GITHUB_ENV
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build
run: |
make build TARGETOS="$GOOS" TARGETARCH="$GOARCH" VERSION="${{ needs.release.outputs.new_tag }}" BINARY_NAME="$BINARY_NAME"
- name: Release with Notes
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.release.outputs.new_tag }}
name: Release ${{ needs.release.outputs.new_tag }}
body: ${{ needs.release.outputs.changelog }}
draft: false
files: ${{env.BINARY_NAME}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}