|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ["v*"] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +env: |
| 11 | + GO_VERSION: "1.27.x" |
| 12 | + WAILS_VERSION: v2.16.0 |
| 13 | + VERSION_FLAG: -X github.com/bugraskl/sweepkit/internal/version.Version=${{ github.ref_name }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + cli: |
| 17 | + name: Command-line tool |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v7 |
| 21 | + - uses: actions/setup-go@v7 |
| 22 | + with: |
| 23 | + go-version: ${{ env.GO_VERSION }} |
| 24 | + - run: go test ./internal/... ./cmd/... |
| 25 | + - name: Build |
| 26 | + run: | |
| 27 | + for target in windows/amd64 windows/arm64 linux/amd64 linux/arm64; do |
| 28 | + os="${target%/*}"; arch="${target#*/}"; ext="" |
| 29 | + [ "$os" = windows ] && ext=".exe" |
| 30 | + CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -trimpath -ldflags "-s -w $VERSION_FLAG" \ |
| 31 | + -o "out/${os}_${arch}/sweepkit${ext}" ./cmd/sweepkit |
| 32 | + done |
| 33 | + - uses: actions/upload-artifact@v7 |
| 34 | + with: |
| 35 | + name: cli |
| 36 | + path: out/ |
| 37 | + |
| 38 | + gui-windows: |
| 39 | + name: Desktop app (Windows) |
| 40 | + runs-on: windows-latest |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v7 |
| 43 | + - uses: actions/setup-go@v7 |
| 44 | + with: |
| 45 | + go-version: ${{ env.GO_VERSION }} |
| 46 | + - run: go install github.com/wailsapp/wails/v2/cmd/wails@${{ env.WAILS_VERSION }} |
| 47 | + - name: Build |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + jq --arg v "${GITHUB_REF_NAME#v}" '.info.productVersion = $v' wails.json > wails.tmp && mv wails.tmp wails.json |
| 51 | + for arch in amd64 arm64; do |
| 52 | + wails build -clean -trimpath -skipbindings -platform "windows/$arch" -ldflags "-s -w $VERSION_FLAG" -o sweepkit-gui.exe |
| 53 | + mkdir -p "out/windows_$arch" |
| 54 | + mv build/bin/sweepkit-gui.exe "out/windows_$arch/" |
| 55 | + done |
| 56 | + - uses: actions/upload-artifact@v7 |
| 57 | + with: |
| 58 | + name: gui-windows |
| 59 | + path: out/ |
| 60 | + |
| 61 | + gui-linux: |
| 62 | + name: Desktop app (Linux ${{ matrix.arch }}) |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + include: |
| 66 | + - arch: amd64 |
| 67 | + runner: ubuntu-22.04 |
| 68 | + - arch: arm64 |
| 69 | + runner: ubuntu-22.04-arm |
| 70 | + runs-on: ${{ matrix.runner }} |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v7 |
| 73 | + - uses: actions/setup-go@v7 |
| 74 | + with: |
| 75 | + go-version: ${{ env.GO_VERSION }} |
| 76 | + - run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev |
| 77 | + - run: go install github.com/wailsapp/wails/v2/cmd/wails@${{ env.WAILS_VERSION }} |
| 78 | + - name: Build |
| 79 | + run: | |
| 80 | + wails build -clean -trimpath -skipbindings -tags webkit2_41 -ldflags "-s -w $VERSION_FLAG" -o sweepkit-gui |
| 81 | + mkdir -p "out/linux_${{ matrix.arch }}" |
| 82 | + mv build/bin/sweepkit-gui "out/linux_${{ matrix.arch }}/" |
| 83 | + - uses: actions/upload-artifact@v7 |
| 84 | + with: |
| 85 | + name: gui-linux-${{ matrix.arch }} |
| 86 | + path: out/ |
| 87 | + |
| 88 | + publish: |
| 89 | + name: Publish release |
| 90 | + needs: [cli, gui-windows, gui-linux] |
| 91 | + runs-on: ubuntu-latest |
| 92 | + permissions: |
| 93 | + contents: write |
| 94 | + id-token: write |
| 95 | + attestations: write |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v7 |
| 98 | + - uses: actions/download-artifact@v8 |
| 99 | + with: |
| 100 | + path: out/ |
| 101 | + merge-multiple: true |
| 102 | + - uses: actions/setup-go@v7 |
| 103 | + with: |
| 104 | + go-version: ${{ env.GO_VERSION }} |
| 105 | + - run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.47.0 |
| 106 | + - run: bash scripts/package.sh "$GITHUB_REF_NAME" |
| 107 | + - uses: actions/attest-build-provenance@v4 |
| 108 | + with: |
| 109 | + subject-path: dist/* |
| 110 | + - name: Create GitHub release |
| 111 | + env: |
| 112 | + GH_TOKEN: ${{ github.token }} |
| 113 | + run: | |
| 114 | + gh release create "$GITHUB_REF_NAME" dist/* \ |
| 115 | + --title "sweepkit $GITHUB_REF_NAME" \ |
| 116 | + --notes-file stage/NOTES.md \ |
| 117 | + --verify-tag |
0 commit comments