1
0
Fork 0
mirror of synced 2024-05-18 19:42:54 +12:00

Workflows: Add version reusable workflow

This commit is contained in:
loathingKernel 2023-12-26 17:24:26 +02:00
parent e5b445d37a
commit 9a56f4b079
3 changed files with 44 additions and 23 deletions

41
.github/workflows/job_version.yml vendored Normal file
View file

@ -0,0 +1,41 @@
name: job_version
on:
workflow_call:
outputs:
tag_abbrev:
value: ${{ jobs.version.outputs.tag_abbrev }}
tag_offset:
value: ${{ jobs.version.outputs.tag_offset }}
sha_short:
value: ${{ jobs.version.outputs.sha_short }}
full_desc:
value: ${{ jobs.version.outputs.full_desc }}
branch:
value: ${{ jobs.version.outputs.branch }}
jobs:
version:
name: Version
runs-on: ubuntu-latest
outputs:
tag_abbrev: ${{ steps.describe.outputs.tag_abbrev }}
tag_offset: ${{ steps.describe.outputs.tag_offset }}
sha_short: ${{ steps.describe.outputs.sha_short }}
full_desc: ${{ steps.describe.outputs.full_desc }}
branch: ${{ steps.describe.outputs.branch }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Describe
id: describe
shell: bash
run: |
tag_abbrev=$(git tag --sort=v:refname | grep -oE "(^[0-9]+\.[0-9]+(.[0-9]+)?)$" | tail -1)
echo "tag_abbrev=$tag_abbrev" >> $GITHUB_OUTPUT
echo "tag_offset=$(git rev-list $tag_abbrev..HEAD --count)" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "full_desc=$(git describe --long --tags)" >> $GITHUB_OUTPUT
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT

View file

@ -13,7 +13,7 @@ permissions:
jobs:
describe:
title:
name: Version ${{ github.ref_name }}
runs-on: ubuntu-latest
steps:

View file

@ -14,29 +14,9 @@ jobs:
version:
name: Describe
runs-on: ubuntu-latest
outputs:
tag_abbrev: ${{ steps.describe.outputs.tag_abbrev }}
tag_offset: ${{ steps.describe.outputs.tag_offset }}
sha_short: ${{ steps.describe.outputs.sha_short }}
full_desc: ${{ steps.describe.outputs.full_desc }}
branch: ${{ steps.describe.outputs.branch }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Describe version
id: describe
shell: bash
run: |
tag_abbrev=$(git tag --sort=v:refname | grep -oE "(^[0-9]+\.[0-9]+(.[0-9]+)?)$" | tail -1)
echo "tag_abbrev=$tag_abbrev" >> $GITHUB_OUTPUT
echo "tag_offset=$(git rev-list $tag_abbrev..HEAD --count)" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "full_desc=$(git describe --long --tags)" >> $GITHUB_OUTPUT
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
uses: ./.github/workflows/job_version.yml
describe:
title:
needs: version
name: Version ${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}
runs-on: ubuntu-latest