|
| 1 | +name: Publish Module |
| 2 | + |
| 3 | +on: workflow_dispatch |
| 4 | + |
| 5 | +jobs: |
| 6 | + publish-module: |
| 7 | + name: Tag Release and Publish to Forge |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - name: Checkout code |
| 11 | + uses: actions/checkout@v2 |
| 12 | + with: |
| 13 | + ref: ${{ github.ref }} |
| 14 | + clean: true |
| 15 | + fetch-depth: 0 |
| 16 | + - name: Get Version |
| 17 | + id: gv |
| 18 | + run: | |
| 19 | + echo "::set-output name=ver::$(jq --raw-output .version metadata.json)" |
| 20 | + - name: Install the PDK |
| 21 | + run: | |
| 22 | + source /etc/os-release |
| 23 | + wget https://apt.puppet.com/puppet-tools-release-${UBUNTU_CODENAME}.deb |
| 24 | + sudo dpkg -i puppet-tools-release-${UBUNTU_CODENAME}.deb |
| 25 | + rm -f puppet-tools-release-${UBUNTU_CODENAME}.deb |
| 26 | + sudo apt-get update |
| 27 | + sudo apt-get install pdk |
| 28 | + pdk bundle install |
| 29 | + - name: Validate Docs |
| 30 | + run: | |
| 31 | + set -e |
| 32 | + documentation=$(pdk bundle exec puppet strings generate --format markdown) |
| 33 | + if [ $(echo $documentation | grep -Ec "[1-9]+ undocumented|\[warn\]") -gt 0 ]; then |
| 34 | + echo "Please resolve documentation issues detected below:" |
| 35 | + echo $documentation |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | + if output=$(git status --porcelain) && [ ! -z "$output" ]; then |
| 39 | + echo "Here is the current git status:" |
| 40 | + git status |
| 41 | + echo |
| 42 | + echo "The following changes were detected:" |
| 43 | + git --no-pager diff |
| 44 | + echo "Please submit a PR of changes after running 'pdk bundle exec puppet strings generate --format markdown'" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + - name: Validate Changelog |
| 48 | + env: |
| 49 | + CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + run: | |
| 51 | + set -e |
| 52 | + pdk bundle exec rake changelog |
| 53 | + check_prs=$(grep -c '### UNCATEGORIZED PRS; LABEL THEM ON GITHUB' CHANGELOG.md) || echo "Check PRs success" |
| 54 | + if [ $check_prs -gt 0 ]; then |
| 55 | + echo "Uncategorized PRs found. Please address missing labels in the PRs below:" |
| 56 | + git --no-pager diff CHANGELOG.md |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + if output=$(git status --porcelain) && [ ! -z "$output" ]; then |
| 60 | + echo "Here is the current git status:" |
| 61 | + git status |
| 62 | + echo |
| 63 | + echo "The following changes were detected:" |
| 64 | + git --no-pager diff |
| 65 | + echo "Uncommitted PRs found in the changelog. Please submit a PR of changes after running 'pdk bundle exec rake changelog'" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | + - name: Tag Release |
| 69 | + uses: ncipollo/release-action@v1 |
| 70 | + with: |
| 71 | + tag: ${{ steps.gv.outputs.ver }} |
| 72 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + draft: false |
| 74 | + prerelease: false |
| 75 | + - name: Build Module |
| 76 | + run: pdk build |
| 77 | + - name: Push to Forge |
| 78 | + run: pdk release publish --forge-token ${{ secrets.PUPPET_FORGE_API_KEY }} --force |
0 commit comments