Skip to content

build

build #16

Workflow file for this run

name: build
on:
create:
tags:
- v*
jobs:
build:
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#standard-github-hosted-runners-for-public-repositories
runs-on: ubuntu-latest
env:
NAME: ddns
DIST: dist
strategy:
matrix:
os: [linux]
platform:
- arch: amd64
- arch: arm64
- arch: arm
version: v7
steps:
- name: Checkout
uses: actions/checkout@main
- name: Get Version
id: get_version
shell: bash
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build Golang Binary
shell: bash
run: |
export GOOS=${{ matrix.os }}
export GOARCH=${{ matrix.platform.arch }}
export GOARM=${{ matrix.platform.version }}
go build -o dist/${{ matrix.os }}/${{ matrix.platform.version != '' && '/' || '' }}${{ matrix.platform.version }}/ddns ./cmd
- name: Build and Push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: 'gitsang/ddns:latest, gitsang/ddns:${{ steps.get_version.outputs.VERSION }}'
platforms: ${{ matrix.os }}/${{ matrix.platform.arch }}${{ matrix.platform.version != '' && '/' || '' }}${{ matrix.platform.version }}
build-args: 'DIST=${{ env.DIST }}'