Skip to content

Commit

Permalink
autorelease, autotag: Tag and release non-alpha prereleases too (#36482)
Browse files Browse the repository at this point in the history
It has been a longstanding request to auto-tag and auto-release
non-alpha prerelease versions, particularly betas. Let's make that
happen.

Note that even-numbered "-a.n" versions for Jetpack are considered
alphas, while odd-numbered versions are not (they're what we release to
Atomic). Right now Jetpack doesn't use the auto-tagger or auto-release,
but I see that we've been manually tagging the odd-numbered 'a'
versions in jetpack-production.

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/8374616227
  • Loading branch information
anomiex authored and matticbot committed Mar 21, 2024
1 parent 90e7a32 commit a91601f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion .github/files/autorelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ set -eo pipefail
: "${GITHUB_REPOSITORY:?Build argument needs to be set and non-empty.}"

## Determine tag
if [[ ! "$GITHUB_REF" =~ ^refs/tags/v?[0-9]+(\.[0-9]+)+$ ]]; then
if [[ ! "$GITHUB_REF" =~ ^refs/tags/v?[0-9]+(\.[0-9]+)+(-[a-z0-9._-]+)?$ ]]; then
echo "::error::Expected GITHUB_REF like \`refs/tags/v1.2.3\` or \`refs/tags/1.2.3\`, got \`$GITHUB_REF\`"
exit 1
fi
TAG="${GITHUB_REF#refs/tags/}"

## Check for alphas
if [[ "$TAG" =~ -(alpha|a\.[0-9]*[02468])$ ]]; then
echo "Not creating a release for alpha version $TAG"
exit 0
fi
echo "Creating release for $TAG"

## Determine slug and title format.
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/autorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ on:
push:
tags:
- 'v?[0-9]+.[0-9]+'
- 'v?[0-9]+.[0-9]+-*'
- 'v?[0-9]+.[0-9]+.[0-9]+'
- 'v?[0-9]+.[0-9]+.[0-9]+-*'
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9]+'
- 'v?[0-9]+.[0-9]+.[0-9]+.[0-9]+-*'

jobs:
publish:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/autotagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
VER=$(sed -nEe 's/^## \[?([^]]*)\]? - .*/\1/;T;p;q' CHANGELOG.md || true)
echo "Version from changelog is ${VER:-<unknown>}"
echo "version=$VER" >> "$GITHUB_OUTPUT"
if [[ "$VER" =~ ^[0-9]+(\.[0-9]+)+$ ]]; then
if [[ "$VER" =~ ^[0-9]+(\.[0-9]+)+(-[a-z0-9._-]+)?$ && ! "$VER" =~ -(alpha|a\.[0-9]*[02468])$ ]]; then
echo "Version $VER ok to tag"
echo "run=true" >> "$GITHUB_OUTPUT"
else
Expand All @@ -77,7 +77,7 @@ jobs:
run: |
RUN=true
if [[ -e composer.json ]]; then
TMP=$(jq -r '.require // {} | to_entries[] | select( .value | test( "-(alpha|a.[0-9]+)$" ) ) | "\(.key) (\(.value))"' composer.json)
TMP=$(jq -r '.require // {} | to_entries[] | select( .value | test( "-(alpha|a\\.[0-9]*[02468])$" ) ) | "\(.key) (\(.value))"' composer.json)
if [[ -n "$TMP" ]]; then
echo "::notice::Not tagging due to -alpha deps on ${TMP//$'\n'/ }"
RUN=false
Expand Down

0 comments on commit a91601f

Please sign in to comment.