Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add existing_release option #26

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ When the `release` workflow finishes running, compiled binaries will be uploaded

You can safely test out release automation by creating tags that have a `-` in them; for example: `v2.0.0-rc.1`. Such Releases will be published as _prereleases_ and will not count as a stable release of your extension.

If you have an existing release, you can set `existing_release` input to `"true"` to have the action upload binaries to the tag instead of creating a new one.

## Extensions written in other compiled languages

If you aren't using Go for your compiled extension, you'll need to provide your own script for compiling your extension:
Expand Down
13 changes: 9 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: "release extension"
description: "Generate a release for a precompiled gh extension"
inputs:
gpg_fingerprint:
description: "GPG fingerprint to use for signing releases"
build_script_override:
description: "Path to custom build script for producing binaries to upload"
existing_release:
description: "Upload assets to an existing release"
required: false
default: "false"
go_version:
description: "The Go version to use for compiling (supports semver spec and ranges)"
default: "1.16"
gpg_fingerprint:
description: "GPG fingerprint to use for signing releases"
branding:
color: purple
icon: box
Expand All @@ -19,9 +23,10 @@ runs:
with:
go-version: ${{ inputs.go_version }}
- run: ${{ github.action_path }}/build_and_release.sh
shell: bash
env:
EXISTING_RELEASE: ${{ inputs.existing_release }}
GH_EXT_BUILD_SCRIPT: ${{ inputs.build_script_override }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ github.token }}
GH_EXT_BUILD_SCRIPT: ${{ inputs.build_script_override }}
GPG_FINGERPRINT: ${{ inputs.gpg_fingerprint }}
shell: bash
7 changes: 4 additions & 3 deletions build_and_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ if [ "${#assets[@]}" -eq 0 ]; then
fi

if [ -n "$GPG_FINGERPRINT" ]; then
shasum -a 256 "${assets[@]}" > checksums.txt
shasum -a 256 "${assets[@]}" >checksums.txt
gpg --output checksums.txt.sig --detach-sign checksums.txt
assets+=(checksums.txt checksums.txt.sig)
fi

if ! gh release create "$tag" $prerelease --title="${GITHUB_REPOSITORY#*/} ${tag#v}" --generate-notes -- "${assets[@]}"; then
echo "trying to upload assets to an existing release instead..."
if [ "$EXISTING_RELEASE" = "true" ]; then
gh release upload "$tag" --clobber -- "${assets[@]}"
else
gh release create "$tag" $prerelease --title="${GITHUB_REPOSITORY#*/} ${tag#v}" --generate-notes -- "${assets[@]}"
fi