-
Notifications
You must be signed in to change notification settings - Fork 10
76 lines (68 loc) · 2.48 KB
/
01-get-publish-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
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
id: releaseCheck
run: |
chmod +rx ./.github/scripts/get-release.sh
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 }}