From 94be27e20f1d6d8143d0b92fcfe48560d2d1dc4c Mon Sep 17 00:00:00 2001 From: Vitaly Gashkov Date: Sun, 24 Aug 2025 10:29:26 +0500 Subject: [PATCH] build: add publish workflow --- .github/FUNDING.yml | 1 + .github/workflows/publish.yml | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..abebeb0 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: ['t.me/tribute/app?startapp=dqW2'] diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..16959eb --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,52 @@ +name: Publish + +on: + push: + tags: + - 'v*' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm run build + + # Extract version from package.json and determine release channel + - name: Parse version and determine release channel + id: version + run: | + VERSION=$(node -p "require('./package.json').version") + echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_OUTPUT + + if [[ $VERSION == *"-alpha."* ]]; then + echo "NPM_TAG=alpha" >> $GITHUB_OUTPUT + echo "PRERELEASE=true" >> $GITHUB_OUTPUT + elif [[ $VERSION == *"-beta."* ]]; then + echo "NPM_TAG=beta" >> $GITHUB_OUTPUT + echo "PRERELEASE=true" >> $GITHUB_OUTPUT + else + echo "NPM_TAG=latest" >> $GITHUB_OUTPUT + fi + + # Publish with the appropriate tag + - name: Publish to npm + run: npm publish --tag ${{ steps.version.outputs.NPM_TAG }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + # Only create GitHub releases for stable versions + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + prerelease: ${{ steps.version.outputs.PRERELEASE == 'true' }} + token: ${{ secrets.GITHUB_TOKEN }} + +permissions: + contents: write