diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 5e8f39f..32954b3 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -8,24 +8,11 @@ If everything seems OK, you can proceed to do the following: 1. Update the version string in `internal/version/version.go` and run `make gen`. 2. Add details in `CHANGELOG.md` on what changed. 3. Create a PR with the subject `chore: update version to X.Y.Z` -4. Once the above PR is approved and merged, create a new git tag `vX.Y.Z` pointing to the commit of the above PR merged to `main`: +4. Once the above PR is approved and merged, update your local branch and run `release.sh`. + If the script reports errors, fix them before continuing. + If there are no issues, it will output the Github tag URL. - ```shell - # Ensure your local copy is up to date with main. Be sure to stash any changes first. - git fetch origin - git reset --hard origin/main - # Fetch existing tags first! - git fetch --tags - git tag -a vX.Y.Z -m 'vX.Y.Z' - ``` - -5. Push the tag: - - ```shell - git push origin tag vX.Y.Z - ``` - -6. Visit `https://github.com/coder/agentapi/releases/tag/vX.Y.Z` and "Create release from tag". +5. Visit `https://github.com/coder/agentapi/releases/tag/vX.Y.Z` and "Create release from tag". - Select the tag you pushed previously. - Select the previous tag and "Generate release notes". Amend as required. diff --git a/main.go b/main.go index 571cf32..67fe4f3 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main //go:generate sh -c "go run main.go server --print-openapi dummy > openapi.json" -//go:generate ./set_version.sh +//go:generate ./version.sh import "github.com/coder/agentapi/cmd" func main() { diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..75bab1f --- /dev/null +++ b/release.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -euo pipefail + +GIT_BRANCH="${GIT_BRANCH:-main}" +echo "GIT_BRANCH=${GIT_BRANCH}" +LOCAL_HEAD=$(git rev-parse --short "${GIT_BRANCH}") +echo "LOCAL_HEAD=${LOCAL_HEAD}" +REMOTE_HEAD=$(git rev-parse --short origin/"${GIT_BRANCH}") +echo "REMOTE_HEAD=${REMOTE_HEAD}" +if [[ "${LOCAL_HEAD}" != "${REMOTE_HEAD}" ]]; then + echo "Please ensure your local branch is up to date before continuing." + exit 1 +fi + +VERSION="" +if ! VERSION=$(./version.sh); then + echo "version.sh exited with a non-zero status code. Fix this before continuing." + exit 1 +elif [[ -z "${VERSION}" ]]; then + echo "Version reported by version.sh was empty. Fix this before continuing." + exit 1 +fi + +echo "VERSION=${VERSION}" +./check_unstaged.sh || exit 1 + +if ! grep -q "## v${VERSION}" CHANGELOG.md; then + echo "Please update CHANGELOG.md with details for ${VERSION} before continuing." + exit 1 +fi + +TAG_NAME="v${VERSION}" +echo "TAG_NAME=${TAG_NAME}" +git fetch --tags +git tag -a "${TAG_NAME}" -m "${TAG_NAME}" +git push origin tag "${TAG_NAME}" + +echo "https://github.com/coder/agentapi/releases/new?tag=${TAG_NAME}" diff --git a/set_version.sh b/version.sh similarity index 96% rename from set_version.sh rename to version.sh index d31c32b..7a0d187 100755 --- a/set_version.sh +++ b/version.sh @@ -11,3 +11,5 @@ version=$(go run main.go --version | awk '{print $3}') jq --arg version "${version}" '.info.version = $version' openapi.json > openapi.json.tmp && mv openapi.json.tmp openapi.json jq --arg version "${version}" '.version = $version' chat/package.json > chat/package.json.tmp && mv chat/package.json.tmp chat/package.json + +echo -n "${version}"