71 lines
1.9 KiB
YAML
71 lines
1.9 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
name: Build (${{ matrix.goos }}-${{ matrix.goarch }})
|
|
runs-on:
|
|
- docker
|
|
- ${{ matrix.goarch }}
|
|
strategy:
|
|
matrix:
|
|
goos: [linux, windows, darwin]
|
|
goarch: [amd64, arm64]
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build
|
|
run: |
|
|
export GOOS=${{ matrix.goos }}
|
|
export GOARCH=${{ matrix.goarch }}
|
|
export CGO_ENABLED=0
|
|
go build -v -o sub-cli-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
|
|
|
|
- name: Upload build artifact
|
|
uses: forgejo/upload-artifact@v4
|
|
with:
|
|
name: sub-cli-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
path: sub-cli-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
|
|
retention-days: 7
|
|
|
|
release:
|
|
name: Create Release
|
|
needs: build
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
runs-on: docker
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download all artifacts
|
|
uses: forgejo/download-artifact@v4
|
|
|
|
- name: Display structure of downloaded files
|
|
run: ls -R
|
|
|
|
- name: Create release
|
|
id: create_release
|
|
uses: https://github.com/softprops/action-gh-release@v2
|
|
with:
|
|
name: Release ${{ github.ref_name }}
|
|
draft: false
|
|
prerelease: false
|
|
files: |
|
|
sub-cli-linux-amd64/sub-cli-linux-amd64
|
|
sub-cli-linux-arm64/sub-cli-linux-arm64
|
|
sub-cli-darwin-amd64/sub-cli-darwin-amd64
|
|
sub-cli-darwin-arm64/sub-cli-darwin-arm64
|
|
sub-cli-windows-amd64/sub-cli-windows-amd64.exe
|
|
sub-cli-windows-arm64/sub-cli-windows-arm64.exe
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
|