Skip to content

Commit

Permalink
build: upload apt/rpm/apk packages to fury.io for publishing (#107)
Browse files Browse the repository at this point in the history
We're going to use `fury.io` to host our packages so users don't have to
manually download a `deb`, `rpm`, `apk` file everytime.
  • Loading branch information
jaredallard committed Jun 19, 2024
1 parent 91016c6 commit eae8eac
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
38 changes: 38 additions & 0 deletions .github/scripts/fury-upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Originally adapated from:
# https://github.com/goreleaser/goreleaser/blob/main/scripts/fury-upload.sh
set -euo pipefail

# FURY_PUSH_TOKEN is a secret token that is used to push packages to
# fury (https://fury.io). It is a required environment variable.
FURY_PUSH_TOKEN="${FURY_PUSH_TOKEN}"

# allowed_exts is an array of allowed file extensions that can be
# uploaded to fury.
allowed_exts=("deb" "rpm" "apk")

# Get the file extension
file_ext="${1##*.}"

is_allowed=false
for ext in "${allowed_exts[@]}"; do
if [[ "$ext" == "$file_ext" ]]; then
is_allowed=true
break
fi
done

if [[ "$is_allowed" == "false" ]]; then
exit 0
fi

cd dist
echo "uploading $1"
status="$(curl -s -q -o /dev/null -w "%{http_code}" -F package="@$1" "https://${FURY_PUSH_TOKEN}@push.fury.io/rgst-io/")"
echo "got: $status"
if [[ "$status" == "200" ]] || [[ "$status" == "409" ]]; then
exit 0
fi

# Otherwise, exit with an error
exit 1
5 changes: 3 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ jobs:
args: release --release-notes CHANGELOG.md --clean
env:
BUILD_RC: ${{ github.event.inputs.rc }}
FURY_PUSH_TOKEN: ${{ secrets.FURY_PUSH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ steps.homebrew-tap-github-app.outputs.token }}
MACOS_SIGN_P12: ${{ secrets.MACOS_SIGN_P12 }}
MACOS_SIGN_PASSWORD: ${{ secrets.MACOS_SIGN_PASSWORD }}
MACOS_NOTARY_ISSUER_ID: ${{ secrets.MACOS_NOTARY_ISSUER_ID }}
MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }}
MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ steps.homebrew-tap-github-app.outputs.token }}
9 changes: 9 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ nfpms:
- statically-linked-binary
- changelog-file-missing-in-native-package

publishers:
- name: fury.io
ids:
- packages
env:
- "FURY_PUSH_TOKEN={{ .Env.FURY_PUSH_TOKEN }}"
cmd: ./.github/scripts/fury-upload.sh {{ .ArtifactName }}
disable: '{{ if (isEnvSet "FURY_PUSH_TOKEN") }}false{{ else }}true{{ end }}'

release:
prerelease: "auto"
footer: |-
Expand Down

0 comments on commit eae8eac

Please sign in to comment.