refactor: migrated another script #2
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: Get and save publish version | |
on: | |
workflow_call: | |
# Map the workflow outputs to job outputs | |
outputs: | |
release: | |
description: "If the current tag is a release" | |
value: ${{ jobs.publish.outputs.release }} | |
preRelease: | |
description: "If the current tag is a pre-release" | |
value: ${{ jobs.publish.outputs.preRelease }} | |
version: | |
description: "Which version has the tag" | |
value: ${{ jobs.publish.outputs.version }} | |
jobs: | |
publish: | |
name: Get and save publish version | |
runs-on: ubuntu-24.04 # Use Ubuntu 24.04 explicitly | |
outputs: | |
release: ${{ steps.releaseCheck.outputs.release }} | |
preRelease: ${{ steps.releaseCheck.outputs.preRelease }} | |
version: ${{ steps.getVersion.outputs.version }} | |
steps: | |
- name: ⏬ Checkout repo | |
uses: actions/checkout@v4 | |
- name: 🔄 Init Cache | |
uses: ./.github/actions/npm-cache | |
- name: 💃🕺 Check if release or prerelease | |
uses: actions/github-script@v7 | |
id: releaseCheck | |
with: | |
script: | | |
const { default: getRelease } = await import('${{ github.workspace }}/.github/scripts/get-release.js'); | |
return await getRelease(); | |
run: | | |
chmod +rx ./.github/scripts/ | |
OUTPUT=$(./.github/scripts/get-release.sh) | |
if [[ $OUTPUT == "RELEASE" ]]; | |
then | |
echo "release=true" >> $GITHUB_OUTPUT | |
elif [[ $OUTPUT == "PRE_RELEASE" ]]; | |
then | |
echo "preRelease=true" >> $GITHUB_OUTPUT | |
fi | |
env: | |
GITHUB_REF: ${{ github.ref }} | |
GITHUB_ACTOR: ${{ github.actor }} | |
GITHUB_COMMITISH: ${{ github.event.release.target_commitish }} | |
GITHUB_PRE_RELEASE: ${{ github.event.release.prerelease }} | |
- name: ↔ Extract tag name | |
shell: bash | |
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
id: extractTag | |
- name: 🏷 Get and Set Package Version on Env | |
id: getVersion | |
env: | |
RELEASE: ${{ steps.releaseCheck.outputs.release }} | |
PRE_RELEASE: ${{ steps.releaseCheck.outputs.preRelease }} | |
TAG: ${{ steps.extractTag.outputs.tag }} | |
run: | | |
chmod +rx ./.github/scripts/package-version.sh | |
OUTPUT=$(./.github/scripts/package-version.sh) | |
echo "version=$OUTPUT" >> $GITHUB_OUTPUT | |
- name: 🌳 Log Valid Version | |
env: | |
VALID_SEMVER_VERSION: ${{ steps.getVersion.outputs.version }} | |
run: echo "$VALID_SEMVER_VERSION" | |
- name: 💀 Killing me softly | |
uses: ./.github/actions/cancel-workflow | |
if: failure() | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} |