Skip to content

Release Workflow

Release Workflow #28

Workflow file for this run

name: Release Workflow
on:
workflow_dispatch:
inputs:
release_type:
description: "Release type (patch, minor, major)"
required: true
default: "patch"
jobs:
bump_version:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "21"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Git config
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Release
run: npm run release -- ${{ github.event.inputs.release_type }}
- name: Get version
id: get_version
run: echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- name: Switch Branch
run: git checkout -b release_${{ steps.get_version.outputs.VERSION }}
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: release_${{ steps.get_version.outputs.VERSION }}
lint:
runs-on: ubuntu-latest
needs: bump_version
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: release_${{ needs.bump_version.outputs.VERSION }}
- name: Set commit SHA
id: set_commit_sha
run: echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Set Commit Status Pending
uses: myrotvorets/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
context: lint
description: "Running lint"
sha: ${{ steps.set_commit_sha.outputs.SHA }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "21"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run lint
run: npm run lint
- name: Set Commit Status
uses: myrotvorets/[email protected]
if: ${{ always() }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
context: lint
sha: ${{ steps.set_commit_sha.outputs.SHA }}
test:
runs-on: ubuntu-latest
needs: bump_version
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: release_${{ needs.bump_version.outputs.VERSION }}
- name: Set commit SHA
id: set_commit_sha
run: echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Set Commit Status Pending
uses: myrotvorets/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
context: test
description: "Running test"
sha: ${{ steps.set_commit_sha.outputs.SHA }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "21"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Get installed Playwright version
id: playwright_version
run: echo VERSION="$(node -e "console.log(require('./package-lock.json').packages['node_modules/playwright'].version)")" >> $GITHUB_OUTPUT
- name: Cache playwright binaries
uses: actions/cache@v4
id: playwright_cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.playwright_version.outputs.VERSION }}
- run: npx playwright install chromium
if: steps.playwright_cache.outputs.cache-hit != 'true'
- run: npx playwright install firefox
if: steps.playwright_cache.outputs.cache-hit != 'true'
- name: Run test
run: npm run test
- name: Set Commit Status
uses: myrotvorets/[email protected]
if: ${{ always() }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
context: test
sha: ${{ steps.set_commit_sha.outputs.SHA }}
release:
runs-on: ubuntu-latest
needs:
- bump_version
- lint
- test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "21"
cache: "npm"
- name: Git config
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Git Pull
run: git pull --ff-only origin release_${{ needs.bump_version.outputs.VERSION }}
- name: Push Changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Install dependencies
run: npm ci
- name: Package
run: npm run package
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "a11y-visualizer-chrome.zip, a11y-visualizer-firefox.zip"
tag: v${{ needs.bump_version.outputs.VERSION }}
draft: true