Release New Version #162
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: Release New Version | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseType: | |
description: 'Release type - major, minor or patch' | |
required: false | |
default: '' | |
preReleaseFlavor: | |
description: 'Pre-Release flavor - rc, beta, or anything' | |
required: false | |
default: '' | |
jobs: | |
create-release-draft: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Tag | |
id: prep | |
run: | | |
TAG_NAME=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases | \ | |
jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .tag_name | select (. != null)") | |
IS_DRAFT=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases | \ | |
jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .draft | select (. != null)") | |
if [ -n "${TAG_NAME}" ] && [ "${IS_DRAFT}" == "false" ];then | |
echo "A release has already been published for this run_id (${{ github.run_id }} / ${TAG_NAME})." | |
exit 1 | |
fi | |
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT | |
- name: Checkout | |
uses: actions/checkout@v4 | |
if: ${{ steps.prep.outputs.tag_name == '' }} | |
with: | |
ref: ${{ github.ref }} | |
fetch-depth: 0 | |
- name: Setup Node | |
if: ${{ steps.prep.outputs.tag_name == '' }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: npm | |
- name: Setup Git | |
if: ${{ steps.prep.outputs.tag_name == '' }} | |
run: | | |
git config --global user.name "devx-sauce-bot" | |
git config --global user.email "[email protected]" | |
- name: Install Dependencies | |
if: ${{ steps.prep.outputs.tag_name == '' }} | |
run: | | |
npm ci | |
npx playwright install | |
npx playwright install-deps | |
- name: Generate (Pre-)Release Draft | |
if: ${{ steps.prep.outputs.tag_name == '' }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
if [ -z "${{ github.event.inputs.releaseType }}" ] && [ -z "${{ github.event.inputs.preReleaseFlavor }}" ];then | |
echo "No release type provided." | |
exit 1 | |
fi | |
if [ -n "${{ github.event.inputs.preReleaseFlavor }}" ];then | |
PRE_RELEASE_ARGS="--preRelease=${{ github.event.inputs.preReleaseFlavor }} --github.preRelease" | |
fi | |
npx release-it ${{ github.event.inputs.releaseType }} ${PRE_RELEASE_ARGS} | |
release-windows-bundle: | |
runs-on: windows-latest | |
needs: [create-release-draft] | |
steps: | |
- name: Find Matching Draft Tag | |
# Fetches the `asset_id` of the uploaded bundle. A non-empty `asset_id` signals a successful upload, preventing duplicate uploads in retry attempts. | |
id: prep | |
run: | | |
$res = Invoke-WebRequest -Uri "https://api.github.com/repos/${{ github.repository }}/releases" -Headers @{'Authorization' = "token ${{ github.token }}"} | |
$jsonObj = ConvertFrom-Json $([String]::new($res.Content)) | |
$selectedRelease = $null | |
Foreach ($release in $jsonObj) | |
{ | |
if ( ! $release.body -contains "- jobId: ${{ github.run_id }}}\\n") { | |
continue | |
} | |
if ( ! $release.draft ) { | |
continue | |
} | |
$selectedRelease = $release | |
break | |
} | |
if ( $null -eq $selectedRelease ) { | |
exit 1 | |
} | |
$selectedAsset = $null | |
Foreach ($asset in $selectedRelease.assets) { | |
if ($asset.name -eq "playwright-windows-amd64.zip") { | |
$selectedAsset = $asset | |
} | |
} | |
$tagName = $selectedRelease.tag_name | |
$releaseId = $selectedRelease.id | |
$assetId = $selectedAsset.id | |
echo "version=$tagName" >> $Env:GITHUB_OUTPUT | |
echo "release_id=$releaseId" >> $Env:GITHUB_OUTPUT | |
echo "asset_id=$assetId" >> $Env:GITHUB_OUTPUT | |
- run: Write-Output "${{ steps.prep.outputs.release_id }} - ${{ steps.prep.outputs.version }} - ${{ steps.prep.outputs.asset_id }}" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
with: | |
ref: ${{ steps.prep.outputs.version }} | |
- name: Setup Node | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: npm | |
- name: Update Release Version | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
run: | | |
npm version --no-git-tag-version ${{ steps.prep.outputs.version }} | |
- name: Bundle Directory | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
run: bash ./scripts/bundle.sh | |
- name: List Bundle Contents | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
run: ls -R bundle/ | |
- name: Archive Bundle | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
uses: azure/powershell@v2 | |
with: | |
inlineScript: | | |
Compress-Archive bundle/ playwright-windows-amd64.zip | |
azPSVersion: '3.1.0' | |
- name: Upload Release Asset | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
gh release upload ${{ steps.prep.outputs.version }} playwright-windows-amd64.zip | |
release-macos-bundle: | |
runs-on: macos-latest | |
needs: [create-release-draft] | |
steps: | |
- name: Find Matching Draft Tag | |
# Fetches the `asset_id` of the uploaded bundle. A non-empty `asset_id` signals a successful upload, preventing duplicate uploads in retry attempts. | |
id: prep | |
run: | | |
VERSION=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases | \ | |
jq -r "[.[] | select(.draft == true) | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .tag_name") | |
RELEASE_ID=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases | \ | |
jq -r "[.[] | select(.draft == true) | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .id") | |
if [ "${VERSION}" = "" ];then | |
echo "No draft version found" | |
exit 1 | |
fi | |
ASSET_ID=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases | \ | |
jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .assets | .[] | select(.name == \"playwright-macos-amd64.zip\") | .id | select(. != null)") | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT | |
echo "asset_id=${ASSET_ID}" >> $GITHUB_OUTPUT | |
- run: echo "${{ steps.prep.outputs.release_id }} - ${{ steps.prep.outputs.version }} - ${{ steps.prep.outputs.asset_id }}" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
with: | |
ref: ${{ steps.prep.outputs.version }} | |
- name: Setup Node | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: npm | |
- name: Update Release Version | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
run: | | |
npm version --no-git-tag-version ${{ steps.prep.outputs.version }} | |
- name: Bundle Directory | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
run: bash ./scripts/bundle.sh | |
- name: List Bundle Contents | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
run: ls -R bundle/ | |
- name: Archive Bundle | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
run: zip --symlinks -r playwright-macos-amd64.zip bundle/ | |
- name: Upload Release Asset | |
if: ${{ steps.prep.outputs.asset_id == '' }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
gh release upload ${{ steps.prep.outputs.version }} playwright-macos-amd64.zip | |
publish-release: | |
runs-on: ubuntu-latest | |
needs: [release-windows-bundle, release-macos-bundle] | |
steps: | |
- name: Find Matching Draft Tag | |
id: prep | |
run: | | |
RELEASE_ID=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases | \ | |
jq -r "[.[] | select(.draft == true) | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .id") | |
if [ "${RELEASE_ID}" = "" ];then | |
echo "No draft version found" | |
exit 1 | |
fi | |
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT | |
- name: Publish Release | |
run: | | |
curl -f -X PATCH -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases/${{ steps.prep.outputs.release_id }} \ | |
-d '{"draft":"false"}' | |
post-release-windows-tests: | |
runs-on: ubuntu-latest | |
needs: publish-release | |
env: | |
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}} | |
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup saucectl | |
uses: saucelabs/saucectl-run-action@v4 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
skip-run: true | |
- name: Parse Release Version | |
id: parse_version | |
run: | | |
VERSION=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases | \ | |
jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .tag_name") | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
- name: Cloud Tests (Windows) | |
working-directory: ./tests/fixtures/post-release | |
env: | |
BUILD_ID: Github RUN ID ${{ env.GITHUB_RUN_ID }} | |
run: | | |
saucectl run --runner-version "url: https://github.com/saucelabs/sauce-playwright-runner/releases/download/${{ steps.parse_version.outputs.version }}/playwright-windows-amd64.zip" --config ./.sauce/config_win.yml | |
post-release-macos-tests: | |
runs-on: ubuntu-latest | |
needs: publish-release | |
env: | |
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}} | |
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup saucectl | |
uses: saucelabs/saucectl-run-action@v4 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
skip-run: true | |
- name: Parse Release Version | |
id: parse_version | |
run: | | |
VERSION=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases | \ | |
jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .tag_name") | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
- name: Cloud Tests (MacOS) | |
working-directory: ./tests/fixtures/post-release | |
env: | |
BUILD_ID: Github RUN ID ${{ env.GITHUB_RUN_ID }} | |
run: | | |
saucectl run --runner-version "url: https://github.com/saucelabs/sauce-playwright-runner/releases/download/${{ steps.parse_version.outputs.version }}/playwright-macos-amd64.zip" --config ./.sauce/config_mac.yml | |
post-release-windows-cucumber-tests: | |
runs-on: ubuntu-latest | |
needs: publish-release | |
env: | |
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}} | |
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup saucectl | |
uses: saucelabs/saucectl-run-action@v4 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
skip-run: true | |
- name: Parse Release Version | |
id: parse_version | |
run: | | |
VERSION=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases | \ | |
jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .tag_name") | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
- name: Cloud Tests (Windows) | |
working-directory: ./tests/fixtures/post-release/cucumber | |
env: | |
BUILD_ID: Github RUN ID ${{ env.GITHUB_RUN_ID }} | |
run: | | |
npm ci --production | |
saucectl run --runner-version "url: https://github.com/saucelabs/sauce-playwright-runner/releases/download/${{ steps.parse_version.outputs.version }}/playwright-windows-amd64.zip" --config ./.sauce/config_win.yml | |
post-release-macos-cucumber-tests: | |
runs-on: ubuntu-latest | |
needs: publish-release | |
env: | |
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}} | |
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup saucectl | |
uses: saucelabs/saucectl-run-action@v4 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
skip-run: true | |
- name: Parse Release Version | |
id: parse_version | |
run: | | |
VERSION=$(curl -s -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases | \ | |
jq -r "[.[] | select(.body | contains(\"- jobId: ${{ github.run_id }}\\n\"))] | first | .tag_name") | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
- name: Cloud Tests (MacOS) | |
working-directory: ./tests/fixtures/post-release/cucumber | |
env: | |
BUILD_ID: Github RUN ID ${{ env.GITHUB_RUN_ID }} | |
run: | | |
npm ci --production | |
saucectl run --runner-version "url: https://github.com/saucelabs/sauce-playwright-runner/releases/download/${{ steps.parse_version.outputs.version }}/playwright-macos-amd64.zip" --config ./.sauce/config_mac.yml |