From b9933aace9b6793abe0514303d030d1feb28542d Mon Sep 17 00:00:00 2001 From: Horia Stere Date: Mon, 19 Oct 2026 17:40:24 +0300 Subject: [PATCH] automate publish to store --- .github/workflows/dry-run.yml | 32 +++++++++++++++++++++++++ .github/workflows/publish.yml | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 .github/workflows/dry-run.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/dry-run.yml b/.github/workflows/dry-run.yml new file mode 100644 index 0000000..1a1e5da --- /dev/null +++ b/.github/workflows/dry-run.yml @@ -0,0 +1,32 @@ +name: Dry Run Package + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + dry-run: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: '24' + + - name: Prepare Package Subfolder + run: cp README.md BlinkCard/ + + - name: Install Dependencies + working-directory: BlinkCard + run: npm install + + - name: Execute Dry Run + working-directory: BlinkCard + run: npm publish --access public --dry-run \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..bf205c3 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,45 @@ +name: Publish to NPM + +on: + push: + tags: + - 'v*' # Triggered on version tag push when creating a GitHub Release + +permissions: + id-token: write # Required for npm OIDC Trusted Publishing + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: '24' + + - name: Verify tag matches package version + run: | + TAG="${GITHUB_REF_NAME#v}" + PKG=$(node -p "JSON.parse(require('fs').readFileSync('./BlinkCard/package.json')).version") + if [ "$TAG" != "$PKG" ]; then + echo "::error::Tag version (v$TAG) does not match BlinkCard/package.json version ($PKG)" + exit 1 + fi + echo "Version match verified: v$TAG" + + - name: Prepare Package Subfolder + run: cp README.md BlinkCard/ + + - name: Install Dependencies + working-directory: BlinkCard + run: npm install + + - name: Publish to npm + working-directory: BlinkCard + run: npm publish --access public \ No newline at end of file