From a5c54619e50f2ef7f659793d3169175b75070bc3 Mon Sep 17 00:00:00 2001 From: Greg Walker Date: Fri, 21 Apr 2023 16:03:18 -0500 Subject: [PATCH] publish on creating a release instead of the branch thing --- .github/workflows/publish.yml | 34 +++------------------------------- .github/workflows/tests.yml | 2 +- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 921ad5a..4ee7f59 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,19 +1,14 @@ name: publish release on: - push: - branches: - - releases + release: + types: [published] permissions: id-token: write jobs: - tests: - uses: ./.github/workflows/tests.yml publish: - name: publish release - needs: [tests] runs-on: ubuntu-latest steps: @@ -21,35 +16,12 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 20 + registry-uri: https://registry.npmjs.org - name: update to latest npm run: npm i -g npm - - name: get new version - id: version - uses: actions/github-script@v6 - with: - script: | - const fs = require("fs/promises"); - const pkg = JSON.parse(await fs.readFile("./package.json", { encoding: "utf-8" })); - core.setOutput("version", pkg.version); - name: install dependencies run: npm ci - name: publish run: npm publish --provenance --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: create release - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 - with: - name: v${{ steps.version.outputs.version }} - tag_name: v${{ steps.versions.outputs.version }} - - name: remind author to update the release - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: "Version ${{ steps.versions.outputs.version }} has been published to npm and a GitHub release has been created. Don't forget to update the release notes!" - }) \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 32eec45..6af7435 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,6 @@ name: tests -on: [pull_request, push, workflow_call] +on: [pull_request, push] jobs: test: