Release New Version #52
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@v3 | |
with: | |
ref: ${{ github.ref }} | |
fetch-depth: 0 | |
- name: Setup Node version | |
uses: actions/setup-node@v3 | |
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 }} | |
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} | |
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@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
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@v1 | |
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: | |
runs-on: macos-latest | |
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@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
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@v3 | |
- name: Setup Saucectl | |
run: npm i saucectl -g | |
- 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@v3 | |
- name: Setup Saucectl | |
run: npm i saucectl -g | |
- 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 |