Release New Version #56
Workflow file for this run
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: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
fetch-depth: 0 | |
- name: Setup Node version | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Setup Git | |
run: | | |
git config --global user.name "devx-sauce-bot" | |
git config --global user.email "[email protected]" | |
- name: Install Dependencies | |
run: npm ci | |
- name: Generate (Pre-)Release Draft | |
id: release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
if [ -z "${{ github.event.inputs.releaseType }}" ] && [ -z "${{ github.event.inputs.preReleaseFlavor }}" ]; then | |
echo "No release type provided." | |
exit 1 | |
fi | |
RELEASE_TYPE="${{ github.event.inputs.releaseType }}" | |
if [ -n "${{ github.event.inputs.preReleaseFlavor }}" ];then | |
LATEST_TAG=$(gh release list --limit 1 --json tagName --jq '.[] | .tagName') | |
# NOTE: Expected tag format is {VERSION}-{FLAVOR}.{FLAVOR_VERSION} | |
LATEST_FLAVOR=$(echo ${LATEST_TAG} | awk -F'-' '{ print $2 }' | awk -F'.' '{ print $1 }') | |
if [ "${LATEST_FLAVOR}" == "${{ github.event.inputs.preReleaseFlavor}}" ];then | |
# NOTE: If the inputted pre-release flavor matches the current pre-release flavor, we only | |
# want to increment the pre-release version instead of a full version bump. | |
PRE_RELEASE_ARGS="--preRelease" | |
RELEASE_TYPE="" | |
else | |
PRE_RELEASE_ARGS="--preRelease=${{ github.event.inputs.preReleaseFlavor }} --github.preRelease" | |
fi | |
fi | |
npx release-it ${RELEASE_TYPE} ${PRE_RELEASE_ARGS} | |
TAG_NAME=$(cat version.txt) | |
source .github/helpers/releases.sh | |
RELEASE_ID=$(get_release_id ${{ github.token }} ${{ github.repository }} $TAG_NAME) | |
if [ -z "$RELEASE_ID" ]; then | |
echo "Failed to get the release ID" | |
exit 1 | |
fi | |
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT | |
echo "release_id=${RELEASE_ID}" >> $GITHUB_OUTPUT | |
- name: Outputs | |
run: | | |
echo "tag_name: ${{ steps.release.outputs.tag_name }}" | |
echo "release_id: ${{ steps.release.outputs.release_id }}" | |
outputs: | |
tag_name: ${{ steps.release.outputs.tag_name }} | |
release_id: ${{ steps.release.outputs.release_id }} | |
release-windows-bundle: | |
runs-on: windows-latest | |
needs: [create-release-draft] | |
steps: | |
- name: Verify Dependencies | |
run: | | |
if ( $null -eq "${{ needs.create-release-draft.outputs.tag_name }}" ) { | |
echo "Missing required tag name" | |
exit 1 | |
} | |
if ( $null -eq "${{ needs.create-release-draft.outputs.release_id }}" ) { | |
echo "Missing required release ID" | |
exit 1 | |
} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Update Release Version | |
run: | | |
npm version --no-git-tag-version ${{ needs.create-release-draft.outputs.tag_name }} | |
- name: Install Dependencies | |
run: npm ci | |
- name: Create Bundle | |
run: npm run bundle | |
- name: List Bundle Contents | |
run: ls -R bundle/ | |
- name: Archive Bundle | |
uses: azure/powershell@v2 | |
with: | |
inlineScript: | | |
Compress-Archive bundle/ puppeteer-replay-windows-amd64.zip | |
azPSVersion: '3.1.0' | |
- name: Upload Release Asset | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
gh release upload ${{ needs.create-release-draft.outputs.tag_name }} puppeteer-replay-windows-amd64.zip | |
release-macos-bundle: | |
# macos-latest is arm only | |
runs-on: macos-13 | |
needs: [create-release-draft] | |
steps: | |
- name: Verify Dependencies | |
run: | | |
if [ -z "${{ needs.create-release-draft.outputs.tag_name }}" ]; then | |
echo "Missing required tag name" | |
exit 1 | |
fi | |
if [ -z "${{ needs.create-release-draft.outputs.release_id }}" ]; then | |
echo "Missing required release ID" | |
exit 1 | |
fi | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Update Release Version | |
run: | | |
npm version --no-git-tag-version ${{ needs.create-release-draft.outputs.tag_name }} | |
- name: Install Dependencies | |
run: npm ci | |
- name: Create Bundle | |
run: npm run bundle | |
- name: List Bundle Contents | |
run: ls -R bundle/ | |
- name: Archive Bundle | |
run: zip --symlinks -r puppeteer-replay-macos-amd64.zip bundle/ | |
- name: Upload Release Asset | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
gh release upload ${{ needs.create-release-draft.outputs.tag_name }} puppeteer-replay-macos-amd64.zip | |
publish-release: | |
runs-on: ubuntu-latest | |
needs: [create-release-draft, release-windows-bundle, release-macos-bundle] | |
steps: | |
- name: Verify Dependencies | |
run: | | |
if [ -z "${{ needs.create-release-draft.outputs.release_id }}" ]; then | |
echo "Missing required release ID" | |
exit 1 | |
fi | |
- name: Publish release | |
run: | | |
curl -f -X PATCH -H "Authorization: token ${{ github.token }}" \ | |
https://api.github.com/repos/${{ github.repository }}/releases/${{ needs.create-release-draft.outputs.release_id }} \ | |
-d '{"draft":"false"}' | |
post-release-windows-tests: | |
runs-on: ubuntu-latest | |
needs: [publish-release, create-release-draft] | |
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: Cloud Tests | |
working-directory: ./tests | |
run: | | |
saucectl run --runner-version "url: https://github.com/saucelabs/puppeteer-replay-runner/releases/download/${{ needs.create-release-draft.outputs.tag_name }}/puppeteer-replay-windows-amd64.zip" --config ./.sauce/config-win.yml | |
post-release-macos-tests: | |
runs-on: ubuntu-latest | |
needs: [publish-release, create-release-draft] | |
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: Cloud Tests | |
working-directory: ./tests | |
run: | | |
saucectl run --runner-version "url: https://github.com/saucelabs/puppeteer-replay-runner/releases/download/${{ needs.create-release-draft.outputs.tag_name }}/puppeteer-replay-macos-amd64.zip" --config ./.sauce/config-mac.yml |