Skip to content

Commit

Permalink
(SIMP-10633) Update standardized assets (#164)
Browse files Browse the repository at this point in the history
This commit rolls up various improvements to the GHA tag & release
workflows, particularly:

  * Tagged releases build a matrix of RPMs: (EL8 *and* EL7)
  * Tagged release logic supports pre/post-release tag formats
  * New arguments in `release_rpms.yml`: `path_to_build` and `verbose`
  * Ensure jobs run on `ubuntu-latest`
  * Fixes for variable edge cases and inter-job dependencies

The patch enforces a standardized asset baseline using simp/puppetsync,
and may apply other updates to ensure conformity.

[SIMP-10644] #close
[SIMP-10633] #comment Add `release_rpms` to rubygem-simp-beaker-helpers
  • Loading branch information
op-ct authored Mar 20, 2022
1 parent 6e9b42d commit 63f46a4
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions .github/workflows/tag_deploy_rubygem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# NOTES:
#
# * The CHANGLOG text is altered to remove RPM-style date headers, which don't
# * The CHANGELOG text is altered to remove RPM-style date headers, which don't
# render well as markdown on the GitHub release pages
#
# * By default, the gem is built and released using the standard rake tasks
Expand All @@ -37,12 +37,15 @@
# All keys are optional.
#
---
name: 'Tag: Release to GitHub & rubygems.org'
name: 'Tag: Release to GitHub + rubygems.org (no RPMS)'

on:
push:
tags:
# NOTE: These filter patterns aren't actually regexes:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- '[0-9]+\.[0-9]+\.[0-9]+'
- '[0-9]+\.[0-9]+\.[0-9]+\-[a-z]+[0-9]+'

env:
PUPPET_VERSION: '~> 6'
Expand All @@ -52,19 +55,15 @@ jobs:
releng-checks:
name: "RELENG checks"
if: github.repository_owner == 'simp'
runs-on: ubuntu-18.04
outputs:
build_command: ${{ steps.commands.outputs.build_command }}
release_command: ${{ steps.commands.outputs.release_command }}
pkg_dir: ${{ steps.commands.outputs.pkg_dir }}
runs-on: ubuntu-latest
steps:
- name: "Assert '${{ github.ref }}' is a tag"
run: '[[ "$GITHUB_REF" =~ ^refs/tags/ ]] || { echo "::error ::GITHUB_REF is not a tag: ${GITHUB_REF}"; exit 1 ; }'
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
clean: true
- name: Determing build and release commands
- name: Determine build and release commands
id: commands
run: |
# By default, these are the standard tasks from "bundler/gem_tasks"
Expand Down Expand Up @@ -92,9 +91,7 @@ jobs:
ruby-version: 2.5
bundler-cache: true
- name: Test build the package
env:
GEM_BUILD_COMMAND: ${{ steps.commands.outputs.build_command }}
run: "$GEM_BUILD_COMMAND"
run: "${{ steps.commands.outputs.build_command }}"
- name: "Assert '${{ github.ref }}' matches the package version"
run: |
tag="${GITHUB_REF/refs\/tags\//}"
Expand All @@ -109,22 +106,37 @@ jobs:
name: Deploy GitHub Release
needs: [ releng-checks ]
if: github.repository_owner == 'simp'
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
outputs:
prerelease: ${{ steps.tag-check.outputs.prerelease }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
clean: true
fetch-depth: 0

- name: Get tag & annotation info (${{github.ref}})
id: tag-check
run: |
tag="${GITHUB_REF/refs\/tags\//}"
annotation="$(git for-each-ref "$GITHUB_REF" --format='%(contents)' --count=1)"
annotation_title="$(echo "$annotation" | head -1)"
if [[ "$tag" =~ ^(simp-|v)?[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta|pre|post)?([0-9]+)?)?$ ]]; then
if [ -n "${BASH_REMATCH[2]}" ]; then
prerelease=yes
annotation_title="Pre-release of ${tag}"
fi
else
printf '::error ::Release Tag format is not SemVer, X.Y.Z-R, X.Y.Z-<prerelease>: "%s"\n' "$RELEASE_TAG"
exit 88
fi
echo "::set-output name=tag::${tag}"
echo "::set-output name=prerelease::${prerelease}"
echo "::set-output name=annotation_title::${annotation_title}"
# Prepare annotation body as a file for the next step
Expand All @@ -146,14 +158,14 @@ jobs:
tag_name: ${{ github.ref }}
release_name: ${{ steps.tag-check.outputs.annotation_title }}
body_path: /tmp/annotation.body
prerelease: ${{ steps.tag-check.outputs.prerelease == 'yes'}}
draft: false
prerelease: false

deploy-rubygem:
name: Deploy RubyGem Release
needs: [ releng-checks ]
if: github.repository_owner == 'simp'
runs-on: ubuntu-18.04
needs: [ releng-checks, create-github-release ]
if: (github.repository_owner == 'simp') && (needs.create-github-release.outputs.prerelease != 'yes')
runs-on: ubuntu-latest
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
BUILD_COMMAND: ${{ needs.releng-checks.outputs.build_command }}
Expand Down

0 comments on commit 63f46a4

Please sign in to comment.