diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 311092e..198d9b6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,6 +3,12 @@ name: Publish on: release: types: [created] + workflow_dispatch: + inputs: + tag: + description: Tag to publish + required: true + type: string permissions: contents: read @@ -12,7 +18,15 @@ jobs: publish-npm: runs-on: ubuntu-latest steps: + - name: Validate tag + if: github.event_name == 'workflow_dispatch' + run: gh api --silent "repos/${GITHUB_REPOSITORY}/git/ref/tags/${TAG_NAME}" + env: + GH_TOKEN: ${{ github.token }} + TAG_NAME: ${{ inputs.tag }} - uses: actions/checkout@v3 + with: + ref: ${{ github.event.release.tag_name || inputs.tag }} - uses: actions/setup-node@v3 with: node-version: 18 @@ -20,7 +34,7 @@ jobs: cache: npm - run: npm ci - run: npm test - - run: npm version ${TAG_NAME} --git-tag-version=false + - run: npm version ${TAG_NAME} --git-tag-version=false --allow-same-version env: - TAG_NAME: ${{ github.event.release.tag_name }} + TAG_NAME: ${{ github.event.release.tag_name || inputs.tag }} - run: npm --ignore-scripts publish --provenance