summaryrefslogtreecommitdiffstats
path: root/.github/workflows/build-release.yml
blob: 4524591c0368bd444415a41ee139b63ebf22e303 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# This workflow will build a Windows binary for each architecture and upload it as an artifact.
# If the push is a tag, it will create a release with the binaries attached.
# This build is currently supported on https://github.com/Crown0815/forgejo-runner-windows

name: Build release

on:
  push:
    tags: 'v*'
jobs:
  build:
    name: Build ${{matrix.architecture}}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        architecture: ['386', amd64, arm, arm64]
    steps:
      - uses: actions/checkout@v4
      - name: Build for ${{matrix.architecture}}
        run: |
          env GOOS=windows GOARCH=${{matrix.architecture}} \
          go build \
            -ldflags "-s -w -X gitea.com/gitea/act_runner/internal/pkg/ver.version=${{ github.ref_name }}" \
            -o forgejo-runner-windows-${{matrix.architecture}}.exe

      - uses: actions/upload-artifact@v4
        with:
          name: forgejo-runner-windows-${{matrix.architecture}}
          path: forgejo-runner-windows-${{matrix.architecture}}.exe

  release:
    runs-on: ubuntu-latest
    needs: build
    if: github.event_name == 'push' && github.ref_type == 'tag'
    steps:
      - uses: actions/download-artifact@v4
        with:
          path: .

      - name: Create Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ github.ref_name }}
          files: forgejo-runner-windows-*/forgejo-runner-windows-*.exe
          draft: false
          prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
          token: ${{ secrets.RELEASE_TOKEN }}
          fail_on_unmatched_files: true
          body: See [original release notes](https://code.forgejo.org/forgejo/runner/releases/tag/${{ github.ref_name }}).