Workflow file for this run
This file contains 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: Upload Packages to new release | |
on: | |
release: | |
types: | |
- published | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
env: | |
BINARY: ${{ github.event.repository.name }} | |
CGO_ENABLED: 0 | |
outputs: | |
matrix: ${{ steps.build.outputs.matrix }} | |
steps: | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ^1 | |
- uses: actions/checkout@v4 | |
name: Checkout | |
- name: Test | |
run: make test | |
env: | |
CGO_ENABLED: 1 | |
- name: Build packages | |
id: build | |
run: | | |
go install github.com/goreleaser/nfpm/v2/cmd/[email protected] | |
make nfpm-deb nfpm-rpm | |
make sum-files | |
ARTIFACTS= | |
# Upload all deb and rpm packages | |
for package in *deb *rpm; do ARTIFACTS=${ARTIFACTS}\"$package\",\ ; done | |
echo "matrix={\"file\": [${ARTIFACTS} \"sha256sum\", \"md5sum\"]}" >> "$GITHUB_OUTPUT" | |
- name: Check version | |
id: check_version | |
run: | | |
echo v$(./out/${BINARY}-linux-amd64 -version) | grep "${{ github.event.release.tag_name }}" | |
- name: Artifact | |
id: artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: packages | |
retention-days: 1 | |
path: | | |
*.deb | |
*.rpm | |
sha256sum | |
md5sum | |
- name: Push packages to the stable repo | |
run: make packagecloud-stable | |
env: | |
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} | |
upload: | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: ${{fromJson(needs.build.outputs.matrix)}} | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- name: Upload ${{ matrix.file }} | |
id: upload | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ${{ matrix.file }} | |
asset_name: ${{ matrix.file }} | |
asset_content_type: application/octet-stream |