-
Notifications
You must be signed in to change notification settings - Fork 46
126 lines (115 loc) · 3.05 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
release:
types: [released]
jobs:
test:
name: "Static & Spec Tests (Ruby ${{ matrix.ruby }}, Puppet ${{ matrix.puppet }})"
runs-on: ubuntu-latest
env:
BUNDLE_JOBS: 4
BUNDLE_WITH: "development"
strategy:
matrix:
puppet:
- '7.0'
- '8.0'
ruby:
- '2.7'
- '3.1'
- '3.2'
exclude:
- ruby: '2.7'
puppet: '8.0'
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
env:
PUPPET_GEM_VERSION: ~> ${{ matrix.puppet }}
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
rubygems: 3.2.3
- name: Rubocop
run: bundle exec rake rubocop
- name: Test code
run: bundle exec rake spec
changelog:
name: 'Update CHANGELOG.md'
runs-on: ubuntu-latest
needs: test
if: |
always() &&
startsWith(github.ref, 'refs/tags/v') &&
(needs.test.result == 'success')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.tag_name }}
release-notes: ${{ github.event.release.body }}
- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: 'chore: update changelog'
file_pattern: CHANGELOG.md
tag:
name: 'Set new version in metadata.json'
runs-on: ubuntu-latest
needs: test
if: |
always() &&
startsWith(github.ref, 'refs/tags/v') &&
(needs.test.result == 'success')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
- name: Get Version
id: get_version
uses: battila7/get-version-action@v2
- name: Update metadata.json
uses: jossef/[email protected]
with:
file: metadata.json
field: version
value: ${{ steps.get_version.outputs.version-without-v }}
- name: Commit updated metadata.json
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: 'chore(release): prepare metadata.json'
file_pattern: metadata.json
release:
name: 'Release to Puppet Forge'
runs-on: ubuntu-latest
needs:
- tag
- changelog
if: |
always() &&
startsWith(github.ref, 'refs/tags/v') &&
(needs.changelog.result == 'success') &&
(needs.tag.result == 'success')
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Build and publish Puppet module
uses: barnumbirr/[email protected]
env:
FORGE_API_KEY: ${{ secrets.FORGE_API_KEY }}
REPOSITORY_URL: https://forgeapi.puppet.com/v3/releases