-
Notifications
You must be signed in to change notification settings - Fork 4
50 lines (49 loc) · 1.73 KB
/
build_prepare.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
on:
workflow_call:
outputs:
sha_short:
value: ${{ jobs.prepare.outputs.sha_short }}
new_tag:
value: ${{ jobs.prepare.outputs.new_tag }}
new_tag_short:
value: ${{ jobs.prepare.outputs.new_tag_short }}
name:
value: ${{ jobs.prepare.outputs.name }}
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
sha_short: ${{ steps.info.outputs.sha_short }}
new_tag: ${{ steps.info.outputs.new_tag }}
new_tag_short: ${{ steps.info.outputs.new_tag_short }}
name: ${{ steps.info.outputs.name }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Fetch tags
run: git fetch --prune --unshallow --tags
- name: Get info
id: info
# The tag name should be retrieved lazily, as tagging may be delayed.
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
echo "sha_short=$(git rev-parse --short HEAD))" >> "$GITHUB_OUTPUT"
if [[ "$BRANCH" = "release" ]]; then
TAG=$(git tag --points-at HEAD)
if [[ ! -z "$TAG" ]]; then
echo "new_tag=$TAG" >> "$GITHUB_OUTPUT"
echo "new_tag_short=${TAG#v}" >> "$GITHUB_OUTPUT"
else
echo "name=rc" >> "$GITHUB_OUTPUT"
fi
else
echo "name=nightly" >> "$GITHUB_OUTPUT"
fi
- name: Show info
env:
SHA_SHORT: ${{ steps.info.outputs.sha_short }}
NEW_TAG: ${{ steps.info.outputs.new_tag }}
NEW_TAG_SHORT: ${{ steps.info.outputs.new_tag_short }}
NAME: ${{ steps.info.outputs.name }}
run: echo "sha_short=$SHA_SHORT, new_tag=$NEW_TAG, new_tag_short=$NEW_TAG_SHORT, name=$NAME"