diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 80e08ea..e10e40a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,79 +5,27 @@ on: types: [published] jobs: - prepare: + build-and-publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: "20" - cache: npm - - name: Restore node_modules cache - uses: actions/cache/restore@v3 - id: cache - with: - path: node_modules - key: timestamp${{ hashFiles('package-lock.json') }} + registry-url: "https://registry.npmjs.org" + - name: Install dependencies - if: steps.cache.outputs.cache-hit != 'true' run: npm ci - - name: Cache node modules - if: steps.cache.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 - with: - path: node_modules - key: timestamp${{ hashFiles('package-lock.json') }} - update-version: - needs: prepare - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: main - - uses: actions/setup-node@v4 - with: - node-version: "20" - - name: Update package.json version - run: | - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - - git fetch --all - git checkout main - git pull origin main + - name: Update version + run: | VERSION=${GITHUB_REF#refs/tags/} npm version ${VERSION#v} --no-git-tag-version --allow-same-version - git add package.json - git commit -m "chore(release): ${VERSION} [skip ci]" - git push origin main - publish: - needs: update-version - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v3 - with: - ref: main - - uses: actions/setup-node@v4 - with: - node-version: "20" - registry-url: "https://registry.npmjs.org" - - name: Unpack node_modules - uses: actions/cache/restore@v3 - id: cache - with: - path: node_modules - key: timestamp${{ hashFiles('package-lock.json') }} - - name: Build and publish - run: | - npm run build - npm publish + - name: Build + run: npm run build + + - name: Publish + run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}