Skip to content

test release workflow #10

test release workflow

test release workflow #10

Workflow file for this run

name: Create draft release
on:
pull_request:
branches:
- test_next
jobs:
draft_release:
name: Draft release
if: startsWith(github.head_ref, 'release/')
runs-on: ubuntu-latest
steps:
- name: Checkout files
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Fetch history and git
run: |
git fetch --prune --unshallow --tags
- name: Install
run: npm ci
- name: Build and add dist files
run: |
rm -rf dist/
npm run build:content
git add package* dist/
- name: Parse changelog
id: get_changelog
# using npm changelog below put escaped characters in the output, so opted for raw git log command
run: |
{
echo 'changelog_text<<EOF'
git log $(git describe --tags --abbrev=0)..HEAD --oneline --format="* %h %s (%an)"
echo EOF
} >> "$GITHUB_OUTPUT"
# https://stackoverflow.com/questions/59191913/how-do-i-get-the-output-of-a-specific-step-in-github-actions
# TODO way to force version with title of branch
- name: Determine version bump
id: determine_bump
# https://unix.stackexchange.com/questions/736318/make-grep-exit-1-if-found-and-exit-0-if-not-found
run: |
echo "${{ steps.get_changelog.outputs.changelog_text }}" | grep -q "feat:" && echo "isMinor=true" >> "$GITHUB_OUTPUT" || echo "isMinor=false" >> "$GITHUB_OUTPUT"
echo "${{ steps.get_changelog.outputs.changelog_text }}" | grep -q "\!:" && echo "isBreakingChange=true" >> "$GITHUB_OUTPUT" || echo "isBreakingChange=false" >> "$GITHUB_OUTPUT"
shell: bash
- name: Config git user
run: |
echo "ACTING" "${{ github.actor}}"
git config user.name "${{ github.actor}}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
# run: |
# git config user.name "${{ github.actor}}"
# git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
- name: Increment version
id: bump_version
run: |
npm version ${{ (steps.determine_bump.outputs.isBreakingChange=='true' && 'major') || (steps.determine_bump.outputs.isMinor=='true' && 'minor') || 'patch' }} --force -m "chore(release): Bumps version to v%s and updates dist files"
echo updated_version=$(node -p "require('./package.json').version") >> "$GITHUB_OUTPUT"
- name: Build notes
id: build_notes
uses: mikepenz/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
owner: Laboratoria
# fromTag: v...
# toTag: v...
- name: Make release draft
id: release_draft
run: |
echo ${{ steps.bump_version.outputs.updated_version }}
echo ${{ steps.build_notes.outputs.changelog }}
# run: |
# gh release create ${{ steps.version_tag_release_draft.outputs.new_tag }} \
# --repo="$GITHUB_REPOSITORY" \
# --title="${GITHUB_REPOSITORY#*/} ${{ steps.version_tag_release_draft.outputs.new_tag }}" \
# --notes ${{steps.build_notes.outputs.changelog}} \
# --draft