A release workflow must run when a tag `v1.2.3` is pushed and publish a GitHub Release with notes.
BeginnerScenarioGitHub Actions
Answer
Situation read → Tag-triggered release.
What I'd do →
on:
push:
tags: ['v*.*.*']
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: gh release create "$GITHUB_REF_NAME" --generate-notes dist/*
env: { GH_TOKEN: "${{ github.token }}" }
Why → gh release create --generate-notes builds notes from merged PRs, and contents: write is scoped to this workflow.
Interview tip → Keep write permissions only on the job that needs them.
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate