diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..e5f279e --- /dev/null +++ b/.github/workflows/release.yaml @@ -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