Skip to content

Commit 23e3491

Browse files
authored
chore: switch to manual release instead of semantic-release (#59)
1 parent ef022c9 commit 23e3491

7 files changed

Lines changed: 157 additions & 89 deletions

File tree

.github/workflows/ci.yml

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -104,62 +104,49 @@ jobs:
104104
run: npm run testenv:stop
105105
if: always()
106106

107-
build-publish:
108-
permissions:
109-
contents: write
110-
id-token: write
111-
issues: write
112-
pull-requests: write
107+
version:
113108
runs-on: ubuntu-latest
114-
needs:
115-
- lint
116-
- test
109+
needs: [test]
110+
outputs:
111+
next_version: ${{ steps.calc.outputs.next_version }}
117112
steps:
118-
- name: Generate release bot app token
119-
id: generate_token
120-
uses: actions/create-github-app-token@v2
121-
with:
122-
app-id: ${{ secrets.HIROSYSTEMS_RELEASE_BOT_ID }}
123-
private-key: ${{ secrets.HIROSYSTEMS_RELEASE_BOT_PEM }}
124-
125113
- uses: actions/checkout@v6
126114
with:
127115
fetch-depth: 0
128-
persist-credentials: false
129-
130-
- name: Get bot user ID
131-
id: bot-user-id
132-
run: |
133-
echo "user-id=$(gh api "/users/${{ steps.generate_token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
134-
env:
135-
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
136116

137-
- uses: actions/setup-node@v6
117+
- name: Use Node.js
118+
uses: actions/setup-node@v6
138119
with:
139-
node-version-file: .nvmrc
140-
141-
- name: Upgrade to latest npm
142-
run: |
143-
npm install -g npm@latest
144-
npm -v
120+
node-version-file: '.nvmrc'
145121

146-
- name: Install deps
147-
run: npm ci --audit=false
122+
- name: Install version tools
123+
run: npm install -g conventional-recommended-bump conventional-changelog-conventionalcommits semver
148124

149-
- name: Build
150-
run: npm run build
151-
152-
- name: Semantic Release
153-
uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v6
154-
# Only run on non-PR events or only PRs that aren't from forks
155-
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
156-
env:
157-
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
158-
SEMANTIC_RELEASE_PACKAGE: ${{ github.event.repository.name }}
159-
GIT_AUTHOR_EMAIL: "${{ steps.bot-user-id.outputs.user-id }}+${{ steps.generate_token.outputs.app-slug }}[bot]@users.noreply.github.com"
160-
GIT_COMMITTER_EMAIL: "${{ steps.bot-user-id.outputs.user-id }}+${{ steps.generate_token.outputs.app-slug }}[bot]@users.noreply.github.com"
161-
with:
162-
extra_plugins: |
163-
@semantic-release/changelog@6.0.3
164-
@semantic-release/git@10.0.1
165-
conventional-changelog-conventionalcommits@9.1.0
125+
- name: Calculate next version
126+
id: calc
127+
run: |
128+
BRANCH="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}"
129+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
130+
LATEST_VERSION=${LATEST_TAG#v}
131+
132+
if [ "$BRANCH" = "master" ]; then
133+
BUMP=$(npx conventional-recommended-bump -p conventionalcommits)
134+
NEXT_VERSION=$(npx semver "$LATEST_VERSION" -i "$BUMP")
135+
elif [ "$BRANCH" = "alpha" ] || [ "$BRANCH" = "beta" ]; then
136+
CHANNEL="$BRANCH"
137+
if echo "$LATEST_VERSION" | grep -qE "\-${CHANNEL}\.[0-9]+$"; then
138+
NEXT_VERSION=$(npx semver "$LATEST_VERSION" -i prerelease --preid "$CHANNEL")
139+
else
140+
BUMP=$(npx conventional-recommended-bump -p conventionalcommits)
141+
BASE=$(npx semver "$LATEST_VERSION" -i "$BUMP")
142+
NEXT_VERSION="${BASE}-${CHANNEL}.0"
143+
fi
144+
else
145+
echo "Skipping version calculation for branch '$BRANCH'"
146+
echo "next_version=" >> "$GITHUB_OUTPUT"
147+
exit 0
148+
fi
149+
150+
echo "next_version=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
151+
echo "## Next Version: \`$NEXT_VERSION\`" >> "$GITHUB_STEP_SUMMARY"
152+
echo "Based on branch \`$BRANCH\`, latest tag \`$LATEST_TAG\`" >> "$GITHUB_STEP_SUMMARY"

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Version to release (e.g. 1.3.0 or 1.3.0-beta.0)'
7+
required: true
8+
type: string
9+
10+
jobs:
11+
publish-npm:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
id-token: write
16+
steps:
17+
- name: Checkout tag
18+
uses: actions/checkout@v6
19+
with:
20+
ref: v${{ inputs.version }}
21+
22+
- name: Use Node.js
23+
uses: actions/setup-node@v6
24+
with:
25+
node-version-file: '.nvmrc'
26+
27+
- name: Upgrade npm
28+
run: npm install -g npm@latest
29+
30+
- name: Install deps
31+
run: npm ci --audit=false
32+
33+
- name: Publish to npm
34+
run: npm publish --provenance --access public
35+
36+
github-release:
37+
runs-on: ubuntu-latest
38+
permissions:
39+
contents: write
40+
steps:
41+
- name: Checkout tag
42+
uses: actions/checkout@v6
43+
with:
44+
ref: v${{ inputs.version }}
45+
46+
- name: Create GitHub Release
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
run: |
50+
PRERELEASE_FLAG=""
51+
if echo "${{ inputs.version }}" | grep -q "-"; then
52+
PRERELEASE_FLAG="--prerelease"
53+
fi
54+
gh release create "v${{ inputs.version }}" \
55+
--generate-notes \
56+
$PRERELEASE_FLAG

.releaserc

Lines changed: 0 additions & 23 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11

2-
/ / ▶ API Toolkit
3-
/ --- / A comprehensive collection of tools designed by Hiro to simplify common tasks in
4-
/ / API development.
2+
# API Toolkit
53

6-
[![NPM Package](https://img.shields.io/npm/v/@hirosystems/api-toolkit.svg?style=flat-square)](https://www.npmjs.org/package/@hirosystems/api-toolkit)
4+
[![NPM Package](https://img.shields.io/npm/v/@stacks/api-toolkit.svg?style=flat-square)](https://www.npmjs.org/package/@stacks/api-toolkit)
75

8-
The API Toolkit Library is a comprehensive collection of tools designed by Hiro to simplify common
9-
tasks in API development. This library provides functionalities for database management, application
10-
shutdown handlers, migration helpers, server version management, etc. It aims to streamline the
11-
development process and improve code quality by offering convenient and reusable modules.
6+
The API Toolkit Library is a comprehensive collection of tools designed by Stacks Labs to simplify
7+
common tasks in API development. This library provides functionalities for database management,
8+
application shutdown handlers, migration helpers, server version management, etc. It aims to
9+
streamline the development process and improve code quality by offering convenient and reusable
10+
modules.
1211

1312
## Installation
1413

1514
You can start by installing the API Toolkit Library using npm:
1615

1716
```
18-
npm install @hirosystems/api-toolkit
17+
npm install @stacks/api-toolkit
1918
```
2019

2120
You should also customize the following ENV variables that control how log messages are displayed:

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@hirosystems/api-toolkit",
2+
"name": "@stacks/api-toolkit",
33
"version": "1.12.0",
44
"description": "API development toolkit",
55
"main": "./dist/index.js",
@@ -18,7 +18,7 @@
1818
},
1919
"repository": {
2020
"type": "git",
21-
"url": "git+https://github.com/hirosystems/api-toolkit.git"
21+
"url": "git+https://github.com/stx-labs/api-toolkit.git"
2222
},
2323
"keywords": [
2424
"api",
@@ -28,12 +28,12 @@
2828
"dist/",
2929
"bin/"
3030
],
31-
"author": "Hiro Systems PBC <engineering@hiro.so> (https://hiro.so)",
31+
"author": "Stacks Labs",
3232
"license": "Apache 2.0",
3333
"bugs": {
34-
"url": "https://github.com/hirosystems/api-toolkit/issues"
34+
"url": "https://github.com/stx-labs/api-toolkit/issues"
3535
},
36-
"homepage": "https://github.com/hirosystems/api-toolkit#readme",
36+
"homepage": "https://github.com/stx-labs/api-toolkit#readme",
3737
"prettier": "@stacks/prettier-config",
3838
"engines": {
3939
"node": ">=22"

scripts/release.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
VERSION="${1:-}"
5+
6+
if [ -z "$VERSION" ]; then
7+
echo "Usage: $0 <version>"
8+
echo " e.g. $0 1.3.0"
9+
echo " e.g. $0 1.3.0-beta.0"
10+
exit 1
11+
fi
12+
13+
# Strip leading 'v' if provided
14+
VERSION="${VERSION#v}"
15+
TAG="v${VERSION}"
16+
17+
# Ensure we're on a clean working tree
18+
if [ -n "$(git status --porcelain)" ]; then
19+
echo "Error: Working tree is not clean. Commit or stash changes first."
20+
exit 1
21+
fi
22+
23+
# Ensure we're up to date with remote
24+
git fetch origin
25+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
26+
if [ "$(git rev-parse HEAD)" != "$(git rev-parse "origin/${BRANCH}")" ]; then
27+
echo "Error: Local branch '${BRANCH}' is not up to date with origin. Pull or push first."
28+
exit 1
29+
fi
30+
31+
# Check tag doesn't already exist
32+
if git rev-parse "$TAG" >/dev/null 2>&1; then
33+
echo "Error: Tag '${TAG}' already exists."
34+
exit 1
35+
fi
36+
37+
echo "Updating version to ${VERSION} (tag ${TAG}) on branch ${BRANCH}"
38+
echo ""
39+
40+
# Update root package.json and package-lock.json
41+
echo "Updating root package.json..."
42+
npm version "$VERSION" --no-git-tag-version
43+
44+
echo ""
45+
echo "Done! Version ${VERSION} updated in all package files."
46+
echo "Next steps:"
47+
echo " Create and merge Pull Request with version bump"
48+
echo " Push the tag: git tag v${VERSION} && git push --tags"
49+
echo " Trigger the Release workflow via GitHub UI with version: ${VERSION}"

0 commit comments

Comments
 (0)