Skip to content

Commit

Permalink
Merge branch '1.4' into 1
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 28, 2023
2 parents 5b22f90 + 9724757 commit d933499
Showing 1 changed file with 42 additions and 117 deletions.
159 changes: 42 additions & 117 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,41 @@ jobs:
sudo add-apt-repository -y ppa:ondrej/php
sudo add-apt-repository -y ppa:ondrej/apache2
sudo apt update
sudo apt install -y libapache2-mod-php${{ matrix.php }}
# The requirements from libnss3-dev are for chrome-testing to run properly
sudo apt install -y libapache2-mod-php${{ matrix.php }} libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev libasound2
# ubuntu-latest comes with a current version of google-chrome-stable and chromedriver
# however we want to use the https://developer.chrome.com/blog/chrome-for-testing/ to match
# what a docker based local developer machine would be using
sudo apt remove -y google-chrome-stable chromedriver
# remove old symlink - note /usr/bin/google-chrome-stable is removed by apt remove above
sudo rm /usr/bin/chromedriver
# Get latest versions of chrome + chromedriver from json endpoint
curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json > chrome.json
# Install chrome
wget $(cat chrome.json | jq -r '.channels.Stable.downloads.chrome[] | select(.platform == "linux64").url')
unzip chrome-linux64.zip
sudo ln -s $(pwd)/chrome-linux64/chrome /usr/bin/chrome
# Install chromedriver
wget $(cat chrome.json | jq -r '.channels.Stable.downloads.chromedriver[] | select(.platform == "linux64").url')
unzip chromedriver-linux64.zip
sudo ln -s $(pwd)/chromedriver-linux64/chromedriver /usr/bin/chromedriver
# Setup symlink to google-chrome for the benefit of gha-run-tests
sudo ln -s /usr/bin/chrome /usr/bin/google-chrome
# Verify things are working correctly
echo "Chrome version is: $(google-chrome --version)"
echo "Chromedriver version is: $(chromedriver --version)"
# Remove temporary files
rm chrome.json
rm chrome-linux64.zip
rm chromedriver-linux64.zip
fi
if [[ $GITHUB_REPOSITORY =~ /(silverstripe-spellcheck|recipe-authoring-tools)$ ]] || [[ "${{ matrix.phpunit_suite }}" == "recipe-authoring-tools" ]]; then
sudo apt install -y hunspell libhunspell-dev hunspell-en-us
Expand Down Expand Up @@ -809,124 +842,16 @@ jobs:
name: Check unreleased changes
runs-on: ubuntu-latest
needs: [tests, checkgovernance]
if: ${{ needs.checkgovernance.outputs.can_tag == '1' && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_SHA: ${{ github.sha }}
LATEST_LOCAL_SHA: ${{ needs.tests.outputs.latest_local_sha }}
if: ${{ needs.checkgovernance.outputs.can_tag == '1' && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
outputs:
do_release: ${{ steps.determine-if.outputs.do_release }}
next_tag: ${{ steps.determine-if.outputs.next_tag }}
do_release: ${{ steps.gauge-release.outputs.do_release }}
next_tag: ${{ steps.gauge-release.outputs.next_tag }}
steps:

- name: Determine if should patch release
id: determine-if
run: |
DO_RELEASE=1
# Must be on a minor branch to do a patch release
if ! [[ $GITHUB_REF_NAME =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "Not patch releasing because not on a minor branch"
DO_RELEASE=0
fi
# Validate that this commit is that latest commit for the branch using GitHub API
# We need to check this in case re-rerunning an old job and there have been new commits since
if [[ $DO_RELEASE == "1" ]]; then
# https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28
RESP_CODE=$(curl -w %{http_code} -s -o __response.json \
-X GET "https://api.github.com/repos/${GITHUB_REPOSITORY}/commits?sha=${GITHUB_REF_NAME}&per_page=1" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
)
if [[ $RESP_CODE != "200" ]]; then
echo "Unable to read list of commits - HTTP response code was $RESP_CODE"
exit 1
fi
LATEST_REMOTE_SHA=$(jq -r '.[0].sha' __response.json)
echo "LATEST_REMOTE_SHA is $LATEST_REMOTE_SHA"
echo "LATEST_LOCAL_SHA is $LATEST_LOCAL_SHA"
if [[ $LATEST_REMOTE_SHA != $LATEST_LOCAL_SHA ]]; then
echo "Not patch releasing because latest remote sha is not equal to latest local sha"
DO_RELEASE=0
fi
# Also validate the sha matches GITHUB_SHA, which is what gha-tag-release will use
if [[ $GITHUB_SHA != $LATEST_LOCAL_SHA ]]; then
echo "Not patch releasing because GITHUB_SHA is not equal to latest local sha"
DO_RELEASE=0
fi
fi
# Check is there is an existing tag on the branch using GitHub API
# Note cannot use local `git tag` because actions/checkout by default will not checkout tags
# and you need to checkout full history in order to get them
LATEST_TAG=""
NEXT_TAG=""
if [[ $DO_RELEASE == "1" ]]; then
# https://docs.github.com/en/rest/git/refs?apiVersion=2022-11-28#list-matching-references
RESP_CODE=$(curl -w %{http_code} -s -o __response.json \
-X GET https://api.github.com/repos/${GITHUB_REPOSITORY}/git/matching-refs/tags/${GITHUB_REF_NAME} \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
)
if [[ $RESP_CODE != "200" ]]; then
echo "Unable to read list of tags - HTTP response code was $RESP_CODE"
exit 1
fi
# Get the latest tag
LATEST_TAG=$(jq -r '.[].ref' __response.json | grep -Po '(?<=^refs\/tags\/)[0-9]+\.[0-9]+\.[0-9]+$' | sort -V -r | head -n 1)
echo "LATEST_TAG is $LATEST_TAG"
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
if ! [[ $LATEST_TAG =~ ([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
echo "Not patch releasing because cannot find a matching semver tag on the branch"
DO_RELEASE=0
else
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
NEXT_TAG="$MAJOR.$MINOR.$((PATCH+1))"
echo "NEXT_TAG is $NEXT_TAG"
echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
fi
fi
# Check if there is anything relevant to release using GitHub API
# The API results include all merged pull-requests, not commits
# Pull-requests prefixed with MNT or DOC will not be considered relevant for releasing
if [[ $DO_RELEASE == "1" ]]; then
# Check on github release notes api if there's anything worth releasing
# Compare commits between current sha with latest tag to see if there is anything worth releasing
# https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits
RESP_CODE=$(curl -w %{http_code} -s -o __response.json \
-X GET https://api.github.com/repos/$GITHUB_REPOSITORY/compare/$LATEST_TAG...$GITHUB_SHA?per_page=100 \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
)
if [[ $RESP_CODE != "200" ]]; then
echo "Unable to fetch compare two commits - HTTP response code was $RESP_CODE"
exit 1
fi
# Get commits for text parsing
jq -r '.commits[].commit.message' __response.json > __commits.json
# Parse comits one line at a time
HAS_THINGS_TO_RELEASE=0
while IFS="" read -r line || [[ -n $line ]]; do
if ! [[ "$line" =~ ^(Merge|MNT|DOC) ]] && ! [[ $line =~ ^[[:space:]]*$ ]]; then
HAS_THINGS_TO_RELEASE=1
break
fi
done < __commits.json
if [[ $HAS_THINGS_TO_RELEASE == "0" ]]; then
echo "Not patch releasing because there is nothing relevant to release"
DO_RELEASE=0
fi
fi
echo "do_release output is $DO_RELEASE"
echo "do_release=$DO_RELEASE" >> $GITHUB_OUTPUT
- name: Gauge release
id: gauge-release
uses: silverstripe/gha-gauge-release@v1
with:
latest_local_sha: ${{ needs.tests.outputs.latest_local_sha }}

patchrelease:
name: Patch release
Expand Down

0 comments on commit d933499

Please sign in to comment.