Skip to content
Merged
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
35 changes: 27 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch:
inputs:
tag:
description: "Existing tag to build and attach to its release (for example v0.1.0)"
description: "Release tag to build (for example v0.1.0). The workflow creates it from the current ref if it does not exist."
required: true
type: string

Expand All @@ -28,9 +28,23 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
fetch-depth: 0

- name: Resolve release source
run: |
git fetch --tags --force
if git rev-parse --verify "refs/tags/${RELEASE_TAG}^{commit}" >/dev/null 2>&1; then
git checkout --detach "${RELEASE_TAG}"
echo "TAG_EXISTS=true" >> "$GITHUB_ENV"
else
if [ "${GITHUB_EVENT_NAME}" != "workflow_dispatch" ]; then
echo "tag ${RELEASE_TAG} does not exist" >&2
exit 1
fi
echo "TAG_EXISTS=false" >> "$GITHUB_ENV"
echo "tag ${RELEASE_TAG} does not exist; building ${GITHUB_REF} and creating it from this commit"
fi

- name: Set up Go
uses: actions/setup-go@v5
with:
Expand Down Expand Up @@ -105,11 +119,16 @@ jobs:
"dist/${RELEASE_NAME}/${PROVIDER_ASSET}.sha256" \
--clobber
else
gh release create "${RELEASE_TAG}" \
"${ARCHIVE}" \
"${ARCHIVE}.sha256" \
"dist/${RELEASE_NAME}/${PROVIDER_ASSET}" \
"dist/${RELEASE_NAME}/${PROVIDER_ASSET}.sha256" \
--title "${RELEASE_TAG}" \
CREATE_ARGS=("${RELEASE_TAG}"
"${ARCHIVE}"
"${ARCHIVE}.sha256"
"dist/${RELEASE_NAME}/${PROVIDER_ASSET}"
"dist/${RELEASE_NAME}/${PROVIDER_ASSET}.sha256"
--title "${RELEASE_TAG}"
--generate-notes
)
if [ "${TAG_EXISTS}" != "true" ]; then
CREATE_ARGS+=(--target "$(git rev-parse HEAD)")
fi
gh release create "${CREATE_ARGS[@]}"
fi
10 changes: 7 additions & 3 deletions docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ as a GitHub release.
git push origin v0.1.0
```

4. The `Release` workflow runs on the tag, builds the archive, uploads it to
the tag's GitHub release, and generates release notes. Edit the release notes
if additional operational guidance is needed.
Alternatively, run **Actions → Release → Run workflow** with the desired
tag. If the tag does not exist, the workflow builds the selected ref and
creates the tag at that commit when it publishes the release.

4. The `Release` workflow builds the archive, uploads it to the tag's GitHub
release, and generates release notes. Edit the release notes if additional
operational guidance is needed.

The tag must start with `v` (`v*`). The provider release asset omits the `v`
prefix, for example `terraform-provider-kouja_0.1.0_linux_amd64`.
Expand Down
Loading