Skip to content

Commit 4f776e5

Browse files
author
Qreta Dev
committed
feat(ga): checkout for cargo publish
1 parent 36251ad commit 4f776e5

3 files changed

Lines changed: 57 additions & 21 deletions

File tree

.github/workflows/release.yml

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,37 +105,79 @@ jobs:
105105
path: pkg/*
106106
if-no-files-found: error
107107

108-
release:
109-
name: Release
108+
release-crates:
109+
name: Release to crates.io
110110
runs-on: ubuntu-latest
111111
needs: [build, wasm]
112112
if: startsWith(github.ref, 'refs/tags/v')
113113

114114
steps:
115-
- name: Download all artifacts
115+
- name: Checkout
116+
uses: actions/checkout@v4
117+
118+
- name: Verify tag version matches Cargo.toml
119+
run: |
120+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
121+
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | awk -F'"' '{print $2}')
122+
123+
echo "Tag version: $TAG_VERSION"
124+
echo "Cargo.toml version: $CARGO_VERSION"
125+
126+
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
127+
echo "Error: Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
128+
echo "Please update Cargo.toml to version $TAG_VERSION or create a matching tag"
129+
exit 1
130+
fi
131+
132+
echo "Version match confirmed: $TAG_VERSION"
133+
134+
- name: Publish to crates.io
135+
run: cargo publish
136+
env:
137+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
138+
139+
release-npm:
140+
name: Release to npm
141+
runs-on: ubuntu-latest
142+
needs: [build, wasm]
143+
if: startsWith(github.ref, 'refs/tags/v')
144+
145+
steps:
146+
- name: Download WASM artifact
116147
uses: actions/download-artifact@v4
117148
with:
118-
path: artifacts
149+
name: html2json
150+
path: pkg
119151

120152
- name: Setup Node.js
121153
uses: actions/setup-node@v4
122154
with:
123155
node-version: "24"
124156
registry-url: "https://registry.npmjs.org"
125157

158+
- name: Publish to npm
159+
working-directory: pkg
160+
run: npm publish --access public
161+
162+
release-github:
163+
name: Release to GitHub
164+
runs-on: ubuntu-latest
165+
needs: [build, wasm, release-crates]
166+
if: startsWith(github.ref, 'refs/tags/v')
167+
168+
steps:
169+
- name: Download all artifacts
170+
uses: actions/download-artifact@v4
171+
with:
172+
path: artifacts
173+
126174
- name: Create archives
127175
run: |
128-
129-
# List downloaded artifacts for debugging
130-
echo "Downloaded artifacts:"
131-
ls -la
132176
cd artifacts
133-
ls -la
134177
135-
# Create WASM archive (handle scoped package name)
178+
# Create WASM archive
136179
if [ -d "html2json" ]; then
137180
cd html2json
138-
# Check if scoped package directory exists inside
139181
if [ -d "@qretaio" ]; then
140182
cd "@qretaio"
141183
tar czf ../../../html2json-wasm.tar.gz html2json
@@ -160,18 +202,11 @@ jobs:
160202
cd ..
161203
done
162204
163-
- name: Create release
205+
- name: Create GitHub release
164206
uses: softprops/action-gh-release@v2
165207
with:
166208
files: |
167209
html2json-*
168210
generate_release_notes: true
169211
env:
170212
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171-
172-
- name: Publish to npm
173-
working-directory: artifacts/html2json
174-
run: npm publish --access public
175-
176-
- name: Publish to crates.io
177-
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[package]
22
name = "html2json"
3-
version = "0.5.10"
3+
version = "0.5.12"
44
edition = "2024"
55
description = "HTML to JSON extractor"
66
authors = ["Qreta Dev <qretadev@gmail.com>"]
77
license = "MIT"
88
repository = "https://github.com/qretaio/html2json"
9+
exclude = ["pkg"]
910

1011
[package.metadata.binstall]
1112
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ target }{ archive-suffix }"

0 commit comments

Comments
 (0)