-
Notifications
You must be signed in to change notification settings - Fork 14
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
base: v3
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
|
||
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" | ||
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: 'Puppet Forge' | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With my yellow Foreman hat on: we maintain stable branches as well and if we need to create multiple release then it would be nice if there was a parameter for the base branch. Then you should also take that into account for the target branch name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated it. it defaults to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't specify any default, it should just work regardless of the default branch. |
||
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 | ||
bastelfreak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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 }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One interesting side note: if that's the normal token GH generates on the fly when the action runs, the created PR will not trigger any further GH actions (like CI). Oh, this is not the case for workflow dispatch, TIL |
||
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 | ||
Comment on lines
+54
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can only recommend using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok ok! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love it if we had some logic to automatically detect this based on labels, making it optional but when I looked at it I had trouble coming up with a good solution so this is a good first step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito. I would also love to do this automatically. but one step at a time.