The script .github/workflows/release.yaml
is a GitHub Actions workflow configuration file that automates the release process for a project. Here's a breakdown of its components and steps:
- Trigger: The workflow is triggered by a push to the "develop" branch.
- Workflow Name: "Release"
- Permissions: Grants write permissions for contents and pull-requests.
The workflow consists of two jobs: release-please
and publish
.
- Runs-on: ubuntu-latest (the job will run on the latest Ubuntu runner).
- Outputs: Captures the output
release_created
from therelease-please
step.
Steps:
- Uses release-please-action:
- Action:
googleapis/release-please-action@v4
- ID:
release-please
- With:
token: ${{ secrets.GITHUB_TOKEN }}
- Purpose: This step uses Google's Release Please action to automate the release process, including generating release notes and creating a GitHub release. It outputs whether a release was created.
- Action:
- Runs-on: ubuntu-latest
- Needs: This job depends on the
release-please
job. - Condition: This job will only run if the
release_created
output from therelease-please
job is true (${{ needs.release-please.outputs.release_created }}
).
Steps:
-
Checkout the Repository:
- Action:
actions/checkout@v4
- Purpose: Checks out the repository code.
- Action:
-
Setup Node.js:
- Action:
actions/setup-node@v4
- With:
node-version: 22
registry-url: "https://registry.npmjs.org"
- Purpose: Sets up Node.js environment for version 22 and configures the npm registry URL.
- Action:
-
Setup Bun:
- Action:
oven-sh/setup-bun@v1
- Purpose: Sets up Bun, a fast JavaScript runtime.
- Action:
-
Install Dependencies:
- Command:
bun i
- Purpose: Installs project dependencies using Bun.
- Command:
-
Publish to npm:
- Command:
npm publish
- Environment Variable:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- Purpose: Publishes the package to the npm registry using the npm token for authentication.
- Command:
This workflow automates the release process by using Release Please to manage the creation of releases and publishing the package to npm when a new release is created. The process ensures that releases are consistently managed and published whenever changes are pushed to the "develop" branch.