Add tag-based release workflow with downloadable assets #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.goos }}-${{ matrix.goarch }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - goos: linux | |
| goarch: amd64 | |
| - goos: linux | |
| goarch: arm64 | |
| - goos: darwin | |
| goarch: amd64 | |
| - goos: darwin | |
| goarch: arm64 | |
| - goos: windows | |
| goarch: amd64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Build binary | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p dist | |
| ext="" | |
| if [[ "${{ matrix.goos }}" == "windows" ]]; then | |
| ext=".exe" | |
| fi | |
| out="ticktick-${{ matrix.goos }}-${{ matrix.goarch }}${ext}" | |
| GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" CGO_ENABLED=0 \ | |
| go build -trimpath -ldflags="-s -w" -o "dist/${out}" ./cmd/ticktick | |
| (cd dist && sha256sum "${out}" > "${out}.sha256") | |
| tar -czf "dist/${out}.tar.gz" -C dist "${out}" "${out}.sha256" | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ticktick-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: dist/ticktick-${{ matrix.goos }}-${{ matrix.goarch }}*.tar.gz | |
| publish: | |
| name: Publish GitHub Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: release-assets | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| files: release-assets/**/*.tar.gz |