From 28ee3597d7fd899a3659750559dea2e18bbdb206 Mon Sep 17 00:00:00 2001 From: Clement DEJOIE Date: Wed, 6 Dec 2023 16:50:24 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Publish=20-=20Automatically=20pu?= =?UTF-8?q?blish=20on=20tag=20push=20-=20Replace=20mingjun97/file-regex-re?= =?UTF-8?q?place@v1=20by=20simple=20npm=20script=20-=20Github=20release=20?= =?UTF-8?q?is=20automatically=20create=20-=20actions/checkout@v3=20updated?= =?UTF-8?q?=20to=20v4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../build-and-publish-npm-package.yml | 85 +++++++++---------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/.github/workflows/build-and-publish-npm-package.yml b/.github/workflows/build-and-publish-npm-package.yml index c69f7e38..b55bcccc 100644 --- a/.github/workflows/build-and-publish-npm-package.yml +++ b/.github/workflows/build-and-publish-npm-package.yml @@ -1,49 +1,46 @@ name: Build Design System package on: - push: - branches: - - main - pull_request: - release: - types: [created] + push: + tags: + - "*" jobs: - build: - runs-on: [ubuntu-latest] - steps: - - name: Checkout - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: 18 - registry-url: 'https://npm.pkg.github.com' - scope: '@ZeroGachis' - - # Skip post-install scripts here, as a malicious - # script could steal GITHUB_TOKEN. - - name: Install dependencies - run: npm ci --ignore-scripts - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # `npm rebuild` will run all those post-install scripts for us. - - name: Rebuild & Prepare dependencies - run: npm rebuild && npm run prepare --if-present - - - name: Update package version - uses: mingjun97/file-regex-replace@v1 - with: - regex: '"version": "([0-9.]*)"' - replacement: '"version": "${{ github.ref_name }}"' - include: 'package.json' - - - name: Compile - run: npm run tsc - - - name: Publish - if: startsWith(github.ref, 'refs/tags/') - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + publish: + runs-on: [ ubuntu-latest ] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://npm.pkg.github.com' + scope: '@ZeroGachis' + + # Skip post-install scripts here, as a malicious + # script could steal GITHUB_TOKEN. + - name: Install dependencies + run: npm ci --ignore-scripts + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # `npm rebuild` will run all those post-install scripts for us. + - name: Rebuild & Prepare dependencies + run: npm rebuild && npm run prepare --if-present + + - name: Update package version + run: npm version --no-git-tag-version ${{ github.ref_name }} + + - name: Compile + run: npm run tsc + + - name: Publish + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create release + uses: softprops/action-gh-release@v1 + with: + generate_release_notes: True