diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f84c180..f861677 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,39 +15,41 @@ jobs: releasing: name: releasing runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + pull-requests: write + timeout-minutes: 10 steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-node@v2-beta + - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 + cache: npm + registry-url: 'https://registry.npmjs.org' - name: Set git user run: | - git config --global user.email "<>" - git config --global user.name "openameba" - - name: Log in to npm - run: | - echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc - npm whoami - - name: Extract branch from git ref - run: | - echo "::set-output name=name::${GITHUB_REF#refs/*/}" - echo "::set-output name=version::${GITHUB_REF##*/}" - id: extract_branch + git config --global user.name 'github-actions[bot]' + git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' - name: Versioning - run: npm version ${{ steps.extract_branch.outputs.version }} + run: npm version "${GITHUB_REF##*/}" - name: Publish to npm - run: npm publish + run: npm publish --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Push updates run: | - git push origin ${{ steps.extract_branch.outputs.name }} + git push origin ${{ github.ref_name }} git push origin --tags - name: Create Pull Request run: > - curl - -X POST - -H "Accept: application/vnd.github.v3+json" - -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" - https://api.github.com/repos/${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}/pulls - -d '{"head":"${{ steps.extract_branch.outputs.name }}","base":"${{ github.event.repository.default_branch }}","title":"chore(release): publish"}' + gh pr create + --assignee + --base "${{ github.event.repository.default_branch }}" + --body '' + --head "${{ github.ref_name }}" + --title "chore(release): publish" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}