From f2ac9f93d68bb45f74a2c413070ad9995ce74c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Teles?= Date: Sat, 18 May 2024 07:18:04 -0300 Subject: [PATCH] chore: Update GitHub Actions workflow for releasing and publishing package --- .github/workflows/publish.yml | 47 ++++++++++++++++------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2ebb5fc..7cf7e4c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,49 +1,46 @@ name: Release and Publish Package + on: push: branches: - main + jobs: release: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 + - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: '20' registry-url: 'https://registry.npmjs.org' + - name: Install dependencies run: npm ci + - name: Build run: npm run build - - name: Bump version and create a git tag + + - name: Bump version, create tag, and push changes id: bump_version run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - npm version patch -m "Bump version to %s [skip ci]" - echo ::set-output name=VERSION::$(node -p "require('./package.json').version") - - name: Push changes - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git remote set-url origin https://${{ secrets.GH_PAT }}@github.com/holly-sheets/holly-sheets.git - git push --follow-tags - env: - GH_PAT: ${{ secrets.GH_PAT }} - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + npm version patch -m "Bump version to %s [skip ci]" + git push --follow-tags + echo VERSION=$(node -p "require('./package.json').version") >> $GITHUB_ENV + + - name: Create GitHub Release + uses: ncipollo/release-action@v1 with: - tag_name: ${{ steps.bump_version.outputs.VERSION }} - release_name: Release ${{ steps.bump_version.outputs.VERSION }} - draft: false - prerelease: false + tag: ${{ env.VERSION }} + name: Release ${{ env.VERSION }} + token: ${{ secrets.GITHUB_TOKEN }} + - name: Publish to npm run: npm publish env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN }} \ No newline at end of file + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}