-
Notifications
You must be signed in to change notification settings - Fork 12
50 lines (41 loc) · 1.66 KB
/
extract-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
name: Extract Version
on:
workflow_call:
outputs:
VERSION:
description: "The extracted version (latest or vX.Y.Z)"
value: ${{ jobs.extract-version.outputs.VERSION || 'latest' }}
VERSION_SUFFIX:
description: "The version suffix (empty or -unstable)"
value: ${{ jobs.extract-version.outputs.VERSION_SUFFIX }}
jobs:
extract-version:
runs-on: ubuntu-22.04
outputs:
VERSION: ${{ env.VERSION }}
VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }}
steps:
- name: Extract version (if stable)
if: github.event.ref == 'refs/heads/stable'
run: |
echo "VERSION=latest" >> $GITHUB_ENV
echo "VERSION_SUFFIX=" >> $GITHUB_ENV
- name: Extract version (if unstable)
if: github.event.ref == 'refs/heads/unstable'
run: |
echo "VERSION=latest" >> $GITHUB_ENV
echo "VERSION_SUFFIX=-unstable" >> $GITHUB_ENV
- name: Extract version (if other branch)
if: github.event.ref != 'refs/heads/stable' && github.event.ref != 'refs/heads/unstable' && !startsWith(github.event.ref, 'refs/tags')
run: |
echo "VERSION=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "VERSION_SUFFIX=" >> $GITHUB_ENV
- name: Extract version (if tagged release)
if: startsWith(github.event.ref, 'refs/tags')
run: |
echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
echo "VERSION_SUFFIX=" >> $GITHUB_ENV
- name: Debug - Print environment variables
run: |
echo "[debug] VERSION=${{ env.VERSION }}"
echo "[debug] VERSION_SUFFIX=${{ env.VERSION_SUFFIX }}"