Skip to content

chore: fix permissions in publish.yml (#557) #244

chore: fix permissions in publish.yml (#557)

chore: fix permissions in publish.yml (#557) #244

Workflow file for this run

name: Publish releases
on:
push:
branches: [main]
env:
YARN_ENABLE_GLOBAL_CACHE: false
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
release_tag: ${{ steps.release.outputs.tag_name }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
package-name: corepack
bump-minor-pre-major: true # TODO: remove this when releasing v1.0.0.
npm-publish:
needs: release-please
if: ${{ needs.release-please.outputs.release_created }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Get the Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
with:
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
restore-keys: |
${{runner.os}}-yarn-
- name: Publish to the npm registry
run: |
corepack yarn install --immutable
corepack yarn npm publish
env:
YARN_NPM_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: corepack yarn pack --out corepack.tgz
- name: Add Corepack package archive to GitHub release
run: gh release upload ${{ needs.release-please.outputs.release_tag }} corepack.tgz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}