Initial #2
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: Build DEB Package | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main, master ] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Install nfpm | |
| run: | | |
| go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest | |
| - name: Create output directory | |
| run: | | |
| rm -rf out | |
| mkdir -p out | |
| - name: Update version in nfpm.yaml if tagged | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| sed -i "s/version: \"[^\"]*\"/version: \"$VERSION\"/" nfpm.yaml | |
| - name: Build DEB package | |
| run: | | |
| nfpm pkg --packager deb --target out | |
| - name: Generate checksums | |
| run: | | |
| cd out | |
| sha256sum -b -- * > sha256sum.txt | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: deb-package | |
| path: out/ | |
| - name: Create Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| out/*.deb | |
| out/sha256sum.txt | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |