Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action to create a module release PR #66

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/prepare_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---

name: Prepare Release

on:
workflow_call:
inputs:
version:
description: 'Module version to be released.'
required: false
default: ''
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: ''
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"
bastelfreak marked this conversation as resolved.
Show resolved Hide resolved
BLACKSMITH_FULL_VERSION: "${{ inputs.version }}"

jobs:
prepare_release:
defaults:
run:
working-directory: ${{ inputs.working-directory }}
name: 'Prepare Release'
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
ekohl marked this conversation as resolved.
Show resolved Hide resolved
with:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perforce makes a full clone with:

      - name: "Checkout"
        uses: "actions/checkout@v4"
        with:
          fetch-depth: 0

In my tests that wasn't required. Maybe it's for some edge cases. Based on their git history I didn't find any explanation.

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: bundle environment
run: |
bundle env
bundle list
- name: Update metadata.json to new version
run: |
if [[ -n BLACKSMITH_FULL_VERSION ]] ; then
bundle exec rake module:bump:full
else
bundle exec rake module:bump
fi
- name: Prepare the release
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: Create pull Request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at voxpupuli/puppet-example#82 I wonder if we can come up with some better instructions in the body. For example, it could link to https://voxpupuli.org/docs/releasing_version/ though that isn't really explaining it well for this new process.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was to link to https://voxpupuli.org/docs/releasing_version/ and update it

uses: peter-evans/create-pull-request@v7
with:
commit-message: "Release ${{ inputs.version }}"
branch: release-prep
delete-branch: true
title: "Release ${{ inputs.version }}"
labels: skip-changelog