Skip to content

Commit a824b88

Browse files
authored
Merge pull request #332 from puppetlabs/CONT-739-Update_release.yml
(CONT-739) - Update release.yml
2 parents 9d56997 + 8d455eb commit a824b88

File tree

3 files changed

+80
-23
lines changed

3 files changed

+80
-23
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "release"
22

33
on:
4-
workflow_call:
4+
workflow_dispatch:
55
inputs:
66
target:
77
description: "The target for the release. This can be a commit sha or a branch."
@@ -38,7 +38,7 @@ jobs:
3838
- name: "Get version"
3939
id: "get_version"
4040
run: |
41-
echo "version=$(ruby -e "require 'rubygems'; puts Gem::Specification::load(Dir.glob('*.gemspec').first).version.to_s")" >> $GITHUB_OUTPUT
41+
echo "version=$(ruby -e "require './lib/puppet_editor_services/version'; puts PuppetEditorServices::PUPPETEDITORSERVICESVERSION.to_s")" >> $GITHUB_OUTPUT
4242
- name: "Build"
4343
run: |
4444
bundle exec rake build

.github/workflows/release_prep.yml

Lines changed: 77 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,83 @@ name: "release prep"
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
target:
7-
description: "The target for the release. This can be a commit sha or a branch."
8-
required: false
9-
default: "main"
10-
version:
11-
description: "Version of gem to be released."
12-
required: true
5+
inputs:
6+
target:
7+
description: "The target for the release. This can be a commit sha or a branch."
8+
required: false
9+
default: "main"
10+
type: "string"
11+
version:
12+
description: "Version to be released."
13+
required: true
14+
type: "string"
1315

1416
jobs:
1517
release_prep:
16-
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release_prep.yml@main"
17-
with:
18-
target: "${{ github.event.inputs.target }}"
19-
version: "${{ github.events.inputs.version }}"
20-
secrets: "inherit"
18+
name: "Release prep"
19+
runs-on: "ubuntu-20.04"
20+
21+
steps:
22+
23+
- name: "Checkout"
24+
uses: "actions/checkout@v3"
25+
with:
26+
ref: ${{ github.event.inputs.target }}
27+
clean: true
28+
fetch-depth: 0
29+
30+
- name: "setup ruby"
31+
uses: "ruby/setup-ruby@v1"
32+
with:
33+
ruby-version: "2.7"
34+
bundler-cache: "true"
35+
36+
- name: "bundle environment"
37+
run: |
38+
echo ::group::bundler environment
39+
bundle env
40+
echo ::endgroup::
41+
42+
- name: "Update Version"
43+
run: |
44+
current_version=$(ruby -e "require './lib/puppet_editor_services/version'; puts PuppetEditorServices::PUPPETEDITORSERVICESVERSION.to_s")
45+
sed -i "s/$current_version/${{ github.event.inputs.version }}/g" $(find . -path './lib/**' -name 'version.rb' -not -path "vendor/*")
46+
47+
- name: "Generate changelog"
48+
run: |
49+
export GH_HOST=github.com
50+
gh extension install chelnak/gh-changelog
51+
gh changelog new --next-version v${{ github.event.inputs.version }}
52+
env:
53+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: "Check if a release is necessary"
56+
id: "check"
57+
run: |
58+
git diff --quiet CHANGELOG.md && echo "::set-output name=release::false" || echo "::set-output name=release::true"
59+
60+
- name: "Commit changes"
61+
if: ${{ steps.check.outputs.release == 'true' }}
62+
run: |
63+
git config --local user.email "${{ github.repository_owner }}@users.noreply.github.com"
64+
git config --local user.name "GitHub Actions"
65+
git add .
66+
git commit -m "Release prep v${{ github.event.inputs.version }}"
67+
68+
- name: "Create pull Request"
69+
uses: "peter-evans/create-pull-request@v4"
70+
if: ${{ steps.check.outputs.release == 'true' }}
71+
with:
72+
token: ${{ secrets.GITHUB_TOKEN }}
73+
commit-message: "Release prep v${{ github.event.inputs.version }}"
74+
branch: "release-prep"
75+
delete-branch: true
76+
title: "Release prep v${{ github.event.inputs.version }}"
77+
base: "main"
78+
body: |
79+
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 }}.
80+
Please verify before merging:
81+
- [ ] last [nightly](https://github.com/${{ github.repository }}/actions/workflows/nightly.yml) run is green
82+
- [ ] [Changelog](https://github.com/${{ github.repository }}/blob/release-prep/CHANGELOG.md) is readable and has no unlabeled pull requests
83+
- [ ] 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
84+
labels: "maintenance"

.gitignore

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,4 @@ log/
99
.DS_Store
1010
tmp/
1111
output/
12-
13-
# Ignore the vendored gems
14-
vendor/hiera-eyaml
15-
vendor/molinillo
16-
vendor/puppet-lint
17-
vendor/puppetfile-resolver
18-
vendor/puppet-strings
19-
vendor/yard
12+
vendor/

0 commit comments

Comments
 (0)