Skip to content

Commit

Permalink
Add action to create a module release PR
Browse files Browse the repository at this point in the history
Co-authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
  • Loading branch information
bastelfreak and ekohl committed Dec 19, 2024
1 parent 113b42f commit d0c0213
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/prepare_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---

name: Prepare Release

on:
workflow_call:
inputs:
version:
description: 'Module version to be released.'
required: true
type: string
working-directory:
description: The working directory where all jobs should be executed. Used for modules in subdirectories like a monorepo or a control repository.
default: '.'
required: false
type: string
base-branch:
description: 'The branch that will be used as the origin for the release branch.'
required: false
default: 'master'
type: string

env:
BUNDLE_WITHOUT: development:test:system_tests
GIT_AUTHOR_NAME: Release Automation
GIT_AUTHOR_EMAIL: "${{ github.repository_owner }}@users.noreply.github.com"

jobs:
prepare_release:
defaults:
run:
working-directory: ${{ inputs.working-directory }}
name: 'Puppet Forge'
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.base-branch }}
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
working-directory: ${{ inputs.working-directory }}
- name: Update metadata.json to new version
run: bundle exec rake module:bump_to_version[${{ inputs.version }}]
- name: Update CHANGELOG.md and update REFERENCE.md if required
env:
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bundle exec rake release:prepare
- name: 'Check if a release is necessary'
id: 'check'
run: |
git diff --quiet CHANGELOG.md && echo "release=false" >> $GITHUB_OUTPUT || echo "release=true" >> $GITHUB_OUTPUT
- name: 'Commit changes'
if: ${{ steps.check.outputs.release == 'true' }}
env:
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git switch --create release_prep
git commit --all --message="Release ${{ steps.get_version.outputs.version }}"
gh pr create --title "Release ${{ steps.get_version.outputs.version }}" --label skip-changelog --base ${{ inputs.base-branch }} --fill

0 comments on commit d0c0213

Please sign in to comment.