|
1 | 1 | name: Publish |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - main |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + description: "The npm tag to publish to" |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - latest |
| 12 | + - test |
7 | 13 |
|
8 | | -concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 14 | +concurrency: publish |
9 | 15 |
|
10 | 16 | permissions: {} # each job should define its own permission explicitly |
11 | 17 |
|
|
15 | 21 | if: github.repository == 'Thinkmill/manypkg' |
16 | 22 | runs-on: ubuntu-latest |
17 | 23 | timeout-minutes: 20 |
| 24 | + environment: Release |
18 | 25 | permissions: |
19 | | - contents: write # to create release (changesets/action) |
20 | | - issues: write # to post issue comments (changesets/action) |
21 | | - pull-requests: write # to create pull request (changesets/action) |
| 26 | + contents: write # to push tags |
22 | 27 | id-token: write # to use OpenID Connect token for trusted publishing (changesets/action) |
23 | 28 | steps: |
24 | 29 | - uses: actions/checkout@v4 |
|
28 | 33 | with: |
29 | 34 | node-version: 24 |
30 | 35 |
|
31 | | - - run: git branch -a |
| 36 | + - run: yarn build |
32 | 37 |
|
33 | | - - name: "Create Pull Request or Publish to npm" |
34 | | - uses: changesets/action@v1 |
35 | | - with: |
36 | | - publish: yarn release |
| 38 | + - name: git config |
| 39 | + run: | |
| 40 | + git config --global user.name 'GitHub Actions' |
| 41 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 42 | +
|
| 43 | + - name: version packages |
| 44 | + if: inputs.tag != 'latest' |
| 45 | + run: | |
| 46 | + yarn changeset version --snapshot ${{ inputs.tag }} |
| 47 | + git commit -a -m 'test' |
| 48 | + env: |
| 49 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + |
| 51 | + - name: npm publish, git tag |
| 52 | + run: yarn changeset publish --tag ${{ inputs.tag }} |
| 53 | + |
| 54 | + # reset, then we have a tagged dangling commit |
| 55 | + - name: git push |
| 56 | + if: inputs.tag != 'latest' |
| 57 | + run: | |
| 58 | + git reset HEAD~1 --hard |
| 59 | +
|
| 60 | + - run: git push origin --tags |
0 commit comments