Publish Package to npmjs #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Package to npmjs | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "The version to publish" | |
required: true | |
tag: | |
description: "Tag" | |
required: true | |
default: "latest" | |
type: choice | |
options: | |
- latest | |
- snapshot | |
- next | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
pull-requests: write | |
steps: | |
# Create an access token for the Github Actions Bot app. This one has permissions | |
# to push directly to this repository (only!) without required status checks. | |
- uses: actions/create-github-app-token@v1 | |
id: github-actions-bot-app-token | |
with: | |
app-id: 819772 | |
private-key: ${{ secrets.APOLLO_GITHUB_ACTIONS_BOT_PRIVATE_KEY }} | |
# Check out the repository, using the Github Actions Bot app's token so that we | |
# can push later and override required statuses. | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.github-actions-bot-app-token.outputs.token }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
registry-url: "https://registry.npmjs.org" | |
cache: "yarn" | |
- run: yarn install --immutable --mode=skip-build | |
- name: "@apollo/client-react-streaming: update version" | |
run: | | |
yarn workspace @apollo/client-react-streaming exec npm pkg set "version=${{ inputs.version }}" | |
yarn workspace @apollo/client-react-streaming exec jq '{ version: .version, dependencies: .dependencies, peerDependencies: .peerDependencies }' package.json | |
- name: "@apollo/experimental-nextjs-app-support: update version and dependencies" | |
run: | | |
yarn workspace @apollo/experimental-nextjs-app-support exec npm pkg set "dependencies[@apollo/client-react-streaming]=${{ inputs.version }}" "version=${{ inputs.version }}" | |
yarn workspace @apollo/experimental-nextjs-app-support exec jq '{ version: .version, dependencies: .dependencies, peerDependencies: .peerDependencies }' package.json | |
- name: Commit changes back | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "Release version ${{ inputs.version }}@${{ inputs.tag}} to npm" | |
push_options: "" | |
skip_dirty_check: false | |
tagging_message: "v.${{ inputs.version }}" | |
- name: "@apollo/client-react-streaming: publish" | |
run: yarn workspace @apollo/client-react-streaming exec npm publish --access public --tag ${{ inputs.tag }} --provenance | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: "@apollo/experimental-nextjs-app-support: publish" | |
run: yarn workspace @apollo/experimental-nextjs-app-support exec npm publish --access public --tag ${{ inputs.tag }} --provenance | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |