Skip to content

Commit

Permalink
Merge pull request #332 from puppetlabs/CONT-739-Update_release.yml
Browse files Browse the repository at this point in the history
(CONT-739) - Update release.yml
  • Loading branch information
LukasAud authored Mar 15, 2023
2 parents 9d56997 + 8d455eb commit a824b88
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "release"

on:
workflow_call:
workflow_dispatch:
inputs:
target:
description: "The target for the release. This can be a commit sha or a branch."
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
- name: "Get version"
id: "get_version"
run: |
echo "version=$(ruby -e "require 'rubygems'; puts Gem::Specification::load(Dir.glob('*.gemspec').first).version.to_s")" >> $GITHUB_OUTPUT
echo "version=$(ruby -e "require './lib/puppet_editor_services/version'; puts PuppetEditorServices::PUPPETEDITORSERVICESVERSION.to_s")" >> $GITHUB_OUTPUT
- name: "Build"
run: |
bundle exec rake build
Expand Down
90 changes: 77 additions & 13 deletions .github/workflows/release_prep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,83 @@ name: "release prep"

on:
workflow_dispatch:
inputs:
target:
description: "The target for the release. This can be a commit sha or a branch."
required: false
default: "main"
version:
description: "Version of gem to be released."
required: true
inputs:
target:
description: "The target for the release. This can be a commit sha or a branch."
required: false
default: "main"
type: "string"
version:
description: "Version to be released."
required: true
type: "string"

jobs:
release_prep:
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release_prep.yml@main"
with:
target: "${{ github.event.inputs.target }}"
version: "${{ github.events.inputs.version }}"
secrets: "inherit"
name: "Release prep"
runs-on: "ubuntu-20.04"

steps:

- name: "Checkout"
uses: "actions/checkout@v3"
with:
ref: ${{ github.event.inputs.target }}
clean: true
fetch-depth: 0

- name: "setup ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "2.7"
bundler-cache: "true"

- name: "bundle environment"
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::
- name: "Update Version"
run: |
current_version=$(ruby -e "require './lib/puppet_editor_services/version'; puts PuppetEditorServices::PUPPETEDITORSERVICESVERSION.to_s")
sed -i "s/$current_version/${{ github.event.inputs.version }}/g" $(find . -path './lib/**' -name 'version.rb' -not -path "vendor/*")
- 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: "Check if a release is necessary"
id: "check"
run: |
git diff --quiet CHANGELOG.md && echo "::set-output name=release::false" || echo "::set-output name=release::true"
- 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${{ github.event.inputs.version }}"
- name: "Create pull Request"
uses: "peter-evans/create-pull-request@v4"
if: ${{ steps.check.outputs.release == 'true' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Release prep v${{ github.event.inputs.version }}"
branch: "release-prep"
delete-branch: true
title: "Release prep v${{ github.event.inputs.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"
9 changes: 1 addition & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,4 @@ log/
.DS_Store
tmp/
output/

# Ignore the vendored gems
vendor/hiera-eyaml
vendor/molinillo
vendor/puppet-lint
vendor/puppetfile-resolver
vendor/puppet-strings
vendor/yard
vendor/

0 comments on commit a824b88

Please sign in to comment.