diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1618b83 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,91 @@ +# This workflow builds cross-platform binaries and publishes a GitHub Release +# when a version tag (e.g. v1.2.3) is pushed. + +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + + test: + name: Test + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.26' + + - name: Test + run: go test -v ./... + + build: + name: Build (${{ matrix.goos }}/${{ matrix.goarch }}) + runs-on: ubuntu-latest + needs: test + permissions: + contents: read + strategy: + matrix: + include: + - goos: linux + goarch: amd64 + - goos: linux + goarch: arm64 + - goos: darwin + goarch: amd64 + - goos: darwin + goarch: arm64 + - goos: windows + goarch: amd64 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.26' + + - name: Build binary + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + run: | + OUTPUT="ksef-cli-${{ matrix.goos }}-${{ matrix.goarch }}" + if [ "${{ matrix.goos }}" = "windows" ]; then + OUTPUT="${OUTPUT}.exe" + fi + go build -o "${OUTPUT}" . + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ksef-cli-${{ matrix.goos }}-${{ matrix.goarch }} + path: ksef-cli-${{ matrix.goos }}-${{ matrix.goarch }}* + + release: + name: Create GitHub Release + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Create release and upload binaries + uses: softprops/action-gh-release@v2 + with: + files: artifacts/*