Merge pull request #166 from deric/puppet8 #144
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |