Skip to content
Merged
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
24 changes: 23 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
tags:
- 'v*'
# Manual release from the Actions tab: tags the commit it runs on with the
# version in Cargo.toml (e.g. v0.2.0) and publishes it, for when pushing a
# tag yourself isn't convenient.
workflow_dispatch:
# Dry run: build and package every target (nothing is published) when the
# packaging changes.
pull_request:
Expand Down Expand Up @@ -95,7 +99,7 @@ jobs:
release:
name: Create Release
needs: build
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -106,6 +110,22 @@ jobs:
with:
path: artifacts

- name: Pick the tag
id: tag
run: |
if [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
[ -n "$version" ] || { echo "no version in Cargo.toml" >&2; exit 1; }
tag="v$version"
if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null; then
echo "$tag already exists; push the tag or bump the version" >&2
exit 1
fi
else
tag="$GITHUB_REF_NAME"
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"

- name: Install cosign
uses: sigstore/cosign-installer@v3

Expand All @@ -125,6 +145,8 @@ jobs:
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
target_commitish: ${{ github.sha }}
files: |
artifacts/**/*.tar.gz
artifacts/**/*.zip
Expand Down
Loading