1212 - main
1313
1414permissions :
15- contents : read
15+ contents : write # Required for creating GitHub releases
1616 id-token : write # Required for OIDC trusted publishing
1717
1818jobs :
@@ -87,15 +87,15 @@ jobs:
8787 - name : Generate version
8888 id : version
8989 run : |
90- # Get base version from package.json
91- BASE_VERSION=$(jq -r .version package.json)
92-
9390 if [[ "${{ steps.detect.outputs.is_tag }}" == "true" ]]; then
94- # For tags, use the base version as-is (stable release )
95- NPM_VERSION="${BASE_VERSION }"
91+ # For tags, extract version from git tag (strip 'v' prefix )
92+ NPM_VERSION="${GITHUB_REF#refs/tags/v }"
9693 NPM_TAG="latest"
9794 echo "📦 Publishing stable release: ${NPM_VERSION}"
9895 else
96+ # Get base version from latest tag for pre-releases
97+ LATEST_TAG=$(git describe --tags --abbrev=0)
98+ BASE_VERSION="${LATEST_TAG#v}"
9999 # For main branch, create a pre-release version using git describe
100100 # Format: 0.3.0-next.5.g1a2b3c4 (base-next.commits.hash)
101101 GIT_COMMIT=$(git rev-parse --short HEAD)
@@ -113,29 +113,6 @@ jobs:
113113
114114 echo "Updated package.json to version ${NPM_VERSION}"
115115
116- - name : Validate tag matches package.json version
117- if : steps.detect.outputs.is_tag == 'true'
118- run : |
119- # Extract version from package.json
120- PKG_VERSION=$(jq -r .version package.json)
121-
122- # Extract version from git tag (strip 'v' prefix)
123- TAG_VERSION=${GITHUB_REF#refs/tags/v}
124-
125- echo "Package version: $PKG_VERSION"
126- echo "Tag version: $TAG_VERSION"
127-
128- if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
129- echo "❌ Error: Version mismatch!"
130- echo " package.json version: $PKG_VERSION"
131- echo " Git tag version: $TAG_VERSION"
132- echo ""
133- echo "Please ensure the git tag matches the version in package.json"
134- exit 1
135- fi
136-
137- echo "✅ Version validation passed: $PKG_VERSION"
138-
139116 - name : Check if version exists
140117 id : check-exists
141118 run : |
@@ -169,6 +146,12 @@ jobs:
169146 run : |
170147 echo "⏭️ Pre-release version already exists, skipping"
171148
149+ - name : Create GitHub Release
150+ if : steps.detect.outputs.is_tag == 'true'
151+ run : gh release create "${{ steps.detect.outputs.trigger_name }}" --title "${{ steps.detect.outputs.trigger_name }}" --generate-notes --verify-tag
152+ env :
153+ GH_TOKEN : ${{ github.token }}
154+
172155 publish-demo :
173156 name : publish @ghostty-web/demo to npm
174157 runs-on : ubuntu-latest
@@ -204,16 +187,18 @@ jobs:
204187 id : version
205188 working-directory : demo
206189 run : |
207- BASE_VERSION=$(jq -r .version package.json)
208-
209190 if [[ "${{ steps.detect.outputs.is_tag }}" == "true" ]]; then
210- NPM_VERSION="${BASE_VERSION}"
191+ # For tags, extract version from git tag (strip 'v' prefix)
192+ NPM_VERSION="${GITHUB_REF#refs/tags/v}"
211193 NPM_TAG="latest"
212194 # Pin to exact version to avoid npx cache issues with transitive deps
213- GHOSTTY_WEB_DEP="${BASE_VERSION }"
195+ GHOSTTY_WEB_DEP="${NPM_VERSION }"
214196 else
197+ # Get base version from latest tag for pre-releases
198+ LATEST_TAG=$(git describe --tags --abbrev=0)
199+ BASE_VERSION="${LATEST_TAG#v}"
215200 GIT_COMMIT=$(git rev-parse --short HEAD)
216- COMMITS_SINCE_TAG=$(git rev-list --count HEAD ^$(git describe --tags --abbrev=0 2>/dev/null || echo HEAD) 2>/dev/null || echo "0" )
201+ COMMITS_SINCE_TAG=$(git rev-list --count HEAD ^${LATEST_TAG} )
217202 NPM_VERSION="${BASE_VERSION}-next.${COMMITS_SINCE_TAG}.g${GIT_COMMIT}"
218203 NPM_TAG="next"
219204 # Pin to exact version to avoid npx cache issues with transitive deps
0 commit comments