From 0d0c225f52af0693fb7923a8b8df2681d53c1322 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 19 Dec 2024 16:56:43 +0100 Subject: [PATCH] Add action to create a module release PR Co-authored-by: Ewoud Kohl van Wijngaarden --- .github/workflows/prepare_release.yml | 67 +++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/prepare_release.yml diff --git a/.github/workflows/prepare_release.yml b/.github/workflows/prepare_release.yml new file mode 100644 index 0000000..c572687 --- /dev/null +++ b/.github/workflows/prepare_release.yml @@ -0,0 +1,67 @@ +--- + +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 + BUNDLE_WITH: release + GIT_AUTHOR_NAME: Release Automation + GIT_AUTHOR_EMAIL: "${{ github.repository_owner }}@users.noreply.github.com" + BLACKSMITH_FULL_VERSION: "${{ inputs.version }}" + +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:full + - 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: Create pull Request + uses: peter-evans/create-pull-request@v7 + if: ${{ steps.check.outputs.release == 'true' }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Release ${{ steps.get_version.outputs.version }}" + branch: 'release-prep' + delete-branch: true + title: "Release ${{ steps.get_version.outputs.version }}"