Skip to content

Commit

Permalink
add release prep workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tw1r3 committed Feb 23, 2024
1 parent bc8ef4b commit 1537ba1
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 5 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/module_release_prep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# This is a generic workflow for creating a release prep
# pr for a puppet module.
# It requires that the caller sets `secrets: inherit` to ensure
# that secrets are visible from steps in this workflow.
name: "Module Release Prep"

on:
workflow_dispatch:
inputs:
version:
description: "Module version to be released."
required: true
type: "string"

jobs:
release_prep:
name: "Release prep"
runs-on: "ubuntu-20.04"

steps:

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

- name: "Generate changelog"
run: |
export GH_HOST=github.com
gh extension install chelnak/gh-changelog
gh changelog new --next-version v${{ github.event.inputs.version }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Update metadata.json"
run: |
current_version=$(jq --raw-output .version metadata.json)
# Update version in metadata.json, only matching first occurrence
sed -i "0,/$current_version/s//${{ github.event.inputs.version }}/" $(find . -name 'metadata.json')
- name: "setup ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "3.2"
bundler-cache: "true"
bundler: 2.4.22

- name: "bundle environment"
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::
- name: "Update REFERENCE.md"
run: |
bundle exec rake strings:generate:reference
- name: "Get version"
id: "get_version"
run: |
echo "version=$(jq --raw-output .version metadata.json)" >> $GITHUB_OUTPUT
- 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' }}
run: |
git config --local user.email "${{ github.repository_owner }}@users.noreply.github.com"
git config --local user.name "GitHub Actions"
git add .
git commit -m "Release prep v${{ steps.get_version.outputs.version }}"
- name: "Create pull Request"
uses: "peter-evans/create-pull-request@v5"
if: ${{ steps.check.outputs.release == 'true' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Release prep v${{ steps.get_version.outputs.version }}"
branch: "release-prep"
delete-branch: true
title: "Release prep v${{ steps.get_version.outputs.version }}"
base: "main"
body: |
Automated release-prep through [pdk-templates](https://github.com/puppetlabs/pdk-templates/blob/main/moduleroot/.github/workflows/auto_release.yml.erb) from commit ${{ github.sha }}.
Please verify before merging:
- [ ] last [nightly](https://github.com/${{ github.repository }}/actions/workflows/nightly.yml) run is green
- [ ] [Changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) is readable and has no unlabeled pull requests
- [ ] Ensure the [changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) version and [metadata](https://github.com/${{ github.repository }}/blob/release-prep/metadata.json) version match
labels: "maintenance"
7 changes: 2 additions & 5 deletions .github/workflows/module_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ jobs:
test-${{ env.cache-name }}-
test-
- name: "Static & syntax tests"
run: bundle exec rake test:check test:syntax

- name: "Lint & documentation tests"
run: bundle exec rake test:lint test:doc
- name: "Static & syntax & lint tests"
run: bundle exec rake test:check test:syntax test:lint

- name: "Metadata dependency check"
run: |
Expand Down

0 comments on commit 1537ba1

Please sign in to comment.