name: Prepare release branch on: workflow_dispatch: pull_request_target: types: - closed permissions: contents: write pull-requests: write jobs: prepare: if: ${{ github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} outputs: version: ${{ steps.version-label.outputs.version }} steps: - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 with: submodules: true - name: Configure Git run: | git config --local user.email "actions@github.com" git config --local user.name "Actions Auto Build" - name: Get current version id: version-label run: | VERSION=$(grep version Cargo.toml | head -n 1 | cut -d'"' -f2) echo "version=${VERSION}" >> $GITHUB_OUTPUT - name: Get previous version id: previous-version-label run: | PREVIOUS_VERSION=$(gh api "/repos/${{ github.repository }}/tags?per_page=1" | jq -r '.[] | .name?') echo "previous_version=${PREVIOUS_VERSION}" >> $GITHUB_OUTPUT - name: Generate Release Notes id: generate-release-notes run: | generate() { gh api \ --method POST \ -H "Accept: application/vnd.github+json" \ -H "X-GitHub-Api-Version: 2022-11-28" \ /repos/${{ github.repository }}/releases/generate-notes \ -f tag_name='v${{ steps.version-label.outputs.version }}' \ -f previous_tag='v${{ steps.previous-version-label.outputs.previous_version }}' \ | jq -r ".body" } echo "changelog<> $GITHUB_OUTPUT - name: Update CHANGELOG.md run: | echo "# [v${{ steps.version-label.outputs.version }}] - `date +%Y-%m-%d`" >> CHANGELOG.md.tmp cat <<'EOF' >> CHANGELOG.md.tmp ${{steps.generate-release-notes.outputs.changelog}} ---snip--- EOF cat CHANGELOG.md >> CHANGELOG.md.tmp mv CHANGELOG.md.tmp CHANGELOG.md - name: Update README run: | cargo run --example update-readme - name: Commit Changelog and README run: git add -f CHANGELOG.md README.md - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 with: commit-message: "CHANGELOG.md: add generated portion." title: "Release v${{ steps.version-label.outputs.version }}." body: > This is an automated PR to prepend the automated changelog to CHANGELOG.md.
Please review the changes and adapt them into the changelog proper. delete-branch: true labels: release branch: "release/v${{ steps.version-label.outputs.version }}"