Add CI for binary releases.

This commit is contained in:
Pieter Hollander 2024-02-22 11:42:04 +01:00
parent 9c4de319f9
commit 0d0ae0d213
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg

View file

@ -1,28 +1,42 @@
# # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
# # https://github.com/goreleaser/goreleaser-action
name: Build Golang packages
on:
push:
branches:
- "**"
tags:
- "v*.*.*"
pull_request:
branches:
- "main"
# name: Release Go package
# on: [push]
jobs:
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-docker
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: '>=1.22'
cache: false
- name: release-build-linux-amd64
run: GOOS=linux GOARCH=amd64 go build -v -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-linux-amd64
- name: release-build-linux-arm64
run: GOOS=linux GOARCH=arm64 go build -v -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-linux-arm64
- name: release-build-windows-amd64
run: GOOS=windows GOARCH=amd64 go build -v -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-windows-amd64.exe
- name: release-build-windows-arm64
run: GOOS=windows GOARCH=arm64 go build -v -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-windows-arm64.exe
- name: release-build-darwin-amd64
run: GOOS=darwin GOARCH=amd64 go build -v -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-darwin-amd64
- name: release-build-darwin-arm64
run: GOOS=darwin GOARCH=arm64 go build -v -ldflags="-s -w -X 'main.Version=${{ github.ref_name }}'" -o bin/opendtu-logger-${{ github.ref_name }}-darwin-arm64
# jobs:
# build:
# runs-on: ubuntu-docker
# strategy:
# matrix:
# go-version: [ '1.21' ]
# steps:
# - uses: actions/checkout@v4
# # - name: Setup Go ${{ matrix.go-version }}
# # uses: actions/setup-go@v4
# # with:
# # go-version: ${{ matrix.go-version }}
# # # You can test your matrix by printing the current Go version
# - name: Display Go version
# run: go version
# - name: Run GoReleaser
# uses: goreleaser/goreleaser-action@master
# with:
# version: latest
# args: release --rm-dist
- name: Create release
uses: https://gitea.com/actions/release-action@main
with:
files: |-
bin/**
api_key: '${{secrets.RELEASE_TOKEN}}'