Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 76da286

Browse files
johnstcnmafredri
andauthored
chore: add release automation script (#74)
Co-authored-by: Mathias Fredriksson <[email protected]>
1 parent 7aa0cc8 commit 76da286

File tree

4 files changed

+45
-18
lines changed

4 files changed

+45
-18
lines changed

MAINTAINERS.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,11 @@ If everything seems OK, you can proceed to do the following:
88
1. Update the version string in `internal/version/version.go` and run `make gen`.
99
2. Add details in `CHANGELOG.md` on what changed.
1010
3. Create a PR with the subject `chore: update version to X.Y.Z`
11-
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`:
11+
4. Once the above PR is approved and merged, update your local branch and run `release.sh`.
12+
If the script reports errors, fix them before continuing.
13+
If there are no issues, it will output the Github tag URL.
1214

13-
```shell
14-
# Ensure your local copy is up to date with main. Be sure to stash any changes first.
15-
git fetch origin
16-
git reset --hard origin/main
17-
# Fetch existing tags first!
18-
git fetch --tags
19-
git tag -a vX.Y.Z -m 'vX.Y.Z'
20-
```
21-
22-
5. Push the tag:
23-
24-
```shell
25-
git push origin tag vX.Y.Z
26-
```
27-
28-
6. Visit `https://github.com/coder/agentapi/releases/tag/vX.Y.Z` and "Create release from tag".
15+
5. Visit `https://github.com/coder/agentapi/releases/tag/vX.Y.Z` and "Create release from tag".
2916

3017
- Select the tag you pushed previously.
3118
- Select the previous tag and "Generate release notes". Amend as required.

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package main
22

33
//go:generate sh -c "go run main.go server --print-openapi dummy > openapi.json"
4-
//go:generate ./set_version.sh
4+
//go:generate ./version.sh
55
import "github.com/coder/agentapi/cmd"
66

77
func main() {

release.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
GIT_BRANCH="${GIT_BRANCH:-main}"
5+
echo "GIT_BRANCH=${GIT_BRANCH}"
6+
LOCAL_HEAD=$(git rev-parse --short "${GIT_BRANCH}")
7+
echo "LOCAL_HEAD=${LOCAL_HEAD}"
8+
REMOTE_HEAD=$(git rev-parse --short origin/"${GIT_BRANCH}")
9+
echo "REMOTE_HEAD=${REMOTE_HEAD}"
10+
if [[ "${LOCAL_HEAD}" != "${REMOTE_HEAD}" ]]; then
11+
echo "Please ensure your local branch is up to date before continuing."
12+
exit 1
13+
fi
14+
15+
VERSION=""
16+
if ! VERSION=$(./version.sh); then
17+
echo "version.sh exited with a non-zero status code. Fix this before continuing."
18+
exit 1
19+
elif [[ -z "${VERSION}" ]]; then
20+
echo "Version reported by version.sh was empty. Fix this before continuing."
21+
exit 1
22+
fi
23+
24+
echo "VERSION=${VERSION}"
25+
./check_unstaged.sh || exit 1
26+
27+
if ! grep -q "## v${VERSION}" CHANGELOG.md; then
28+
echo "Please update CHANGELOG.md with details for ${VERSION} before continuing."
29+
exit 1
30+
fi
31+
32+
TAG_NAME="v${VERSION}"
33+
echo "TAG_NAME=${TAG_NAME}"
34+
git fetch --tags
35+
git tag -a "${TAG_NAME}" -m "${TAG_NAME}"
36+
git push origin tag "${TAG_NAME}"
37+
38+
echo "https://github.com/coder/agentapi/releases/new?tag=${TAG_NAME}"

set_version.sh renamed to version.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ version=$(go run main.go --version | awk '{print $3}')
1111

1212
jq --arg version "${version}" '.info.version = $version' openapi.json > openapi.json.tmp && mv openapi.json.tmp openapi.json
1313
jq --arg version "${version}" '.version = $version' chat/package.json > chat/package.json.tmp && mv chat/package.json.tmp chat/package.json
14+
15+
echo -n "${version}"

0 commit comments

Comments
 (0)