ci: add release preview action #12
Workflow file for this run
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: Preview release | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
release: | |
name: Preview release | |
runs-on: ubuntu-latest | |
outputs: | |
new-release-version: ${{ steps.dry-run.outputs.new-release-version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
- name: Install dependencies | |
run: yarn install | |
- name: Preview release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
id: dry-run | |
run: | | |
OUTPUT=$(unset GITHUB_ACTIONS && npx semantic-release --dry-run --no-ci --branches "$GITHUB_HEAD_REF" --repository-url "$github.event.pull_request.head.repo.git_url") | |
VERSION=$(echo "$OUTPUT" | grep -o "The next release version is [0-9]*\.[0-9]*\.[0-9]*" | awk '{print $6}') | |
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | |
- name: Next version | |
run: echo "The next version will be ${{ steps.dry-ryb.outputs.new-release-version }}" |