Skip to content

.github/workflows/on-merge-qvac-lib-decoder-audio.yml #173

.github/workflows/on-merge-qvac-lib-decoder-audio.yml

.github/workflows/on-merge-qvac-lib-decoder-audio.yml #173

name: On Merge Trigger (Decoder-audio)
on:
push:
branches:
- main
- release-*
- feature-*
- tmp-*
paths:
- "packages/qvac-lib-decoder-audio/**"
- ".github/workflows/*decoder-audio*.yml"
workflow_dispatch:
inputs:
tag:
description: "Tag to publish with"
required: false
default: "dev"
type: choice
options:
- latest
- dev
permissions:
contents: read
pull-requests: read
packages: read
id-token: write
jobs:
publish-logic:
runs-on: ubuntu-latest
outputs:
publish_main: ${{ steps.logic.outputs.publish_main }}
publish_release: ${{ steps.logic.outputs.publish_release }}
publish_feature: ${{ steps.logic.outputs.publish_feature }}
publish_tmp: ${{ steps.logic.outputs.publish_tmp }}
gpr_tag: ${{ steps.logic.outputs.gpr_tag }}
steps:
- id: logic
shell: bash
env:
INPUT_TAG: ${{ inputs.tag }}
run: |
set -euo pipefail
ref_name="${GITHUB_REF_NAME}"
event_name="${GITHUB_EVENT_NAME}"
input_tag="${INPUT_TAG}"
publish_main="false"
publish_release="false"
publish_feature="false"
publish_tmp="false"
if [ "$event_name" = "push" ] || [ "$event_name" = "workflow_dispatch" ]; then
if [ "$ref_name" = "main" ]; then
publish_main="true"
elif [[ "$ref_name" == release-* ]]; then
publish_release="true"
elif [[ "$ref_name" == feature-* ]]; then
publish_feature="true"
elif [[ "$ref_name" == tmp-* ]]; then
publish_tmp="true"
fi
fi
gpr_tag="$input_tag"
if [ -z "$gpr_tag" ]; then
if [ "$ref_name" = "main" ]; then
gpr_tag="dev"
elif [[ "$ref_name" == feature-* ]]; then
gpr_tag="feature"
elif [[ "$ref_name" == tmp-* ]]; then
gpr_tag="temp"
else
gpr_tag="dev"
fi
fi
echo "publish_main=$publish_main" >> "$GITHUB_OUTPUT"
echo "publish_release=$publish_release" >> "$GITHUB_OUTPUT"
echo "publish_feature=$publish_feature" >> "$GITHUB_OUTPUT"
echo "publish_tmp=$publish_tmp" >> "$GITHUB_OUTPUT"
echo "gpr_tag=$gpr_tag" >> "$GITHUB_OUTPUT"
release-merge-guard:
name: Release Merge Guard
if: >-
(github.event_name == 'push' || github.event_name == 'workflow_dispatch') &&
startsWith(github.ref_name, 'release-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
fetch-depth: 0
- uses: ./.github/actions/release-merge-guard
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-ref: ${{ github.ref_name }}
base-sha: ${{ github.event.before }}
head-sha: ${{ github.sha }}
package-slug: qvac-lib-decoder-audio
package-json-path: packages/qvac-lib-decoder-audio/package.json
changelog-path: packages/qvac-lib-decoder-audio/CHANGELOG.md
run-integration-tests:
needs: publish-logic
if: |
needs.publish-logic.outputs.publish_main == 'true' ||
needs.publish-logic.outputs.publish_release == 'true' ||
needs.publish-logic.outputs.publish_feature == 'true' ||
needs.publish-logic.outputs.publish_tmp == 'true'
uses: ./.github/workflows/integration-test-qvac-lib-decoder-audio.yml
secrets: inherit
with:
repository: ${{ github.repository }}
ref: ${{ github.sha }}
workdir: "packages/qvac-lib-decoder-audio"
mobile-integration-tests:
needs: publish-logic
permissions:
contents: read
packages: read
pull-requests: write
id-token: write
if: |
needs.publish-logic.outputs.publish_main == 'true' ||
needs.publish-logic.outputs.publish_release == 'true' ||
needs.publish-logic.outputs.publish_feature == 'true' ||
needs.publish-logic.outputs.publish_tmp == 'true'
uses: ./.github/workflows/integration-mobile-test-qvac-lib-decoder-audio.yml
secrets: inherit
with:
repository: ${{ github.repository }}
ref: ${{ github.sha }}
workdir: "packages/qvac-lib-decoder-audio"
publish-gpr:
needs: [publish-logic, run-integration-tests, mobile-integration-tests]
if: |
needs.publish-logic.outputs.publish_main == 'true' ||
needs.publish-logic.outputs.publish_feature == 'true' ||
needs.publish-logic.outputs.publish_tmp == 'true'
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
fetch-depth: 0
- name: Publish to GitHub Packages
uses: ./.github/actions/publish-library-to-gpr
with:
secret-token: ${{ secrets.GITHUB_TOKEN }}
npm-token: ${{ secrets.NPM_TOKEN }}
tag: ${{ needs.publish-logic.outputs.gpr_tag }}
workdir: "packages/qvac-lib-decoder-audio"
name-suffix: "-mono"
publish-release-npm:
needs: [publish-logic, release-merge-guard, run-integration-tests, mobile-integration-tests]
if: |
!cancelled() &&
needs.publish-logic.outputs.publish_release == 'true' &&
needs.release-merge-guard.result == 'success'
runs-on: ubuntu-latest
environment: release
outputs:
published_version: ${{ steps.publish.outputs.npm_published_version }}
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
- name: Publish to NPM Package Registry
id: publish
uses: ./.github/actions/publish-library-to-npm
with:
secret-token: ${{ secrets.NPM_TOKEN }}
tag: "latest"
repo_name: "decoder-audio"
git-token: ${{ secrets.GITHUB_TOKEN }}
workdir: "packages/qvac-lib-decoder-audio"
publish-release:
needs: [publish-release-npm]
if: |
!cancelled() &&
needs.publish-release-npm.result == 'success' &&
needs.publish-release-npm.outputs.published_version != ''
permissions:
contents: write
uses: ./.github/workflows/create-github-release.yml
with:
repo_name: "decoder-audio"
release_name: "QVAC Decoder Audio Lib"
published_version: ${{ needs.publish-release-npm.outputs.published_version }}
prev_sha: ${{ github.event.before }}
workdir: "packages/qvac-lib-decoder-audio"