Skip to content

Commit

Permalink
add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
satta committed Jan 8, 2024
1 parent 43a20fa commit 5fd91b0
Showing 1 changed file with 119 additions and 0 deletions.
119 changes: 119 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Build release

on:
push:
tags:
- 'v*'

jobs:
release:
name: Create Release ${{ github.ref }}
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: release
uses: actions/create-release@latest
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: false
prerelease: false
release_name: ${{ github.ref }}
tag_name: ${{ github.ref }}

unix:
name: Build Unix-like Binaries
needs: release
strategy:
matrix:
arch:
- 386
- amd64
- arm64
os:
- darwin
- linux
exclude:
- os: darwin
arch: 386
runs-on: ubuntu-latest
container:
image: golang:1.21
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Set up user
run: |
useradd -m -g users testuser
chown -R testuser:users .
- name: Build for ${{ matrix.arch }} ${{ matrix.os }}
run: |
su -c "GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -v -o mini-syslog-receiver-${{ matrix.os }}-${{ matrix.arch }}" testuser
- name: Upload Assets
id: upload_try1
continue-on-error: true
uses: shogo82148/actions-upload-release-asset@v1
with:
asset_path: mini-syslog-receiver-${{ matrix.os }}-${{ matrix.arch }}
github_token: ${{ secrets.GITHUB_TOKEN }}
upload_url: ${{ needs.release.outputs.upload_url }}
overwrite: true
- name: Upload Assets (retry)
id: upload_try2
if: steps.upload_try1.outcome == 'failure'
continue-on-error: true
uses: shogo82148/actions-upload-release-asset@v1
with:
asset_path: mini-syslog-receiver-${{ matrix.os }}-${{ matrix.arch }}
github_token: ${{ secrets.GITHUB_TOKEN }}
upload_url: ${{ needs.release.outputs.upload_url }}
overwrite: true

windows:
name: Build Windows Binaries
needs: release
strategy:
matrix:
arch:
- 386
- amd64
- arm64
os:
- windows
exclude:
- os: darwin
arch: 386
runs-on: ubuntu-latest
container:
image: golang:1.21
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Set up user
run: |
useradd -m -g users testuser
chown -R testuser:users .
- name: Build for ${{ matrix.arch }} ${{ matrix.os }}
run: |
su -c "GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -v -o mini-syslog-receiver-${{ matrix.os }}-${{ matrix.arch }}.exe" testuser
- name: Upload Assets
id: upload_try1
continue-on-error: true
uses: shogo82148/actions-upload-release-asset@v1
with:
asset_path: mini-syslog-receiver-${{ matrix.os }}-${{ matrix.arch }}.exe
github_token: ${{ secrets.GITHUB_TOKEN }}
upload_url: ${{ needs.release.outputs.upload_url }}
overwrite: true
- name: Upload Assets (retry)
id: upload_try2
if: steps.upload_try1.outcome == 'failure'
continue-on-error: true
uses: shogo82148/actions-upload-release-asset@v1
with:
asset_path: mini-syslog-receiver-${{ matrix.os }}-${{ matrix.arch }}.exe
github_token: ${{ secrets.GITHUB_TOKEN }}
upload_url: ${{ needs.release.outputs.upload_url }}
overwrite: true

0 comments on commit 5fd91b0

Please sign in to comment.