diff --git a/.github/workflows/latest.yaml b/.github/workflows/latest.yaml new file mode 100644 index 0000000..e97785f --- /dev/null +++ b/.github/workflows/latest.yaml @@ -0,0 +1,61 @@ +name: Publish latest + +on: + workflow_run: + workflows: [Unit tests] + types: + - completed + workflow_dispatch: + +jobs: + latest: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Create or update latest + uses: actions/github-script@v7 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/latest' + sha: context.sha + }).catch(err => { + if (err.status !== 422) throw err; + github.rest.git.updateRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'tags/latest' + sha: context.sha + }); + }) + + - name: Create latest release + uses: softprops/action-gh-release@v1 + with: + name: 'latest' + tag_name: 'ref/tags/latest' + + publish: + runs-on: ubuntu-latest + needs: create-latest + strategy: + matrix: + os: [ linux, darwin ] + arch: [ amd64, arm64 ] + + steps: + - name: Check out + uses: actions/checkout@v4 + + - name: Publish binaries + uses: wangyoucao577/go-release-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: ${{ matrix.os }} + goarch: ${{ matrix.arch }} + release_tag: latest + asset_name: SewerRat-${{ matrix.os }}-${{ matrix.arch }} + overwrite: true + compress_assets: false