From bcb6ee28bf86df7608424eadfd2c510cfc635b37 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 4 Sep 2024 17:43:20 +0100 Subject: [PATCH] Move get version logic to composite action --- .github/actions/get-version/action.yml | 10 ++++++++++ .github/workflows/ci.yml | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .github/actions/get-version/action.yml diff --git a/.github/actions/get-version/action.yml b/.github/actions/get-version/action.yml new file mode 100644 index 000000000..5205f9078 --- /dev/null +++ b/.github/actions/get-version/action.yml @@ -0,0 +1,10 @@ +name: "Get version" +description: "Gets the version number from GitHub environment" + +runs: + using: "composite" + + steps: + - if: github.ref_name != "master" + run: echo "SYNERGY_VERSION=${{ github.event.inputs.version || github.ref_name }}" >> $GITHUB_ENV + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8708c1923..d5efc74b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,6 @@ on: env: GIT_SHA: ${{ github.sha }} - SYNERGY_VERSION: ${{ github.event.inputs.version || github.ref_name }} SYNERGY_PRODUCT_NAME: ${{ vars.SYNERGY_PRODUCT_NAME }} SYNERGY_PACKAGE_PREFIX: ${{ vars.SYNERGY_PACKAGE_PREFIX }} SYNERGY_LICENSED_PRODUCT: ${{ vars.SYNERGY_LICENSED_PRODUCT }} @@ -68,6 +67,9 @@ jobs: with: submodules: "recursive" + - name: Get version + uses: ./.github/actions/get-version + - name: Cache vcpkg dirs uses: actions/cache@v4 with: @@ -166,6 +168,9 @@ jobs: with: submodules: "recursive" + - name: Get version + uses: ./.github/actions/get-version + - name: Cache deps dir uses: actions/cache@v4 with: @@ -286,6 +291,9 @@ jobs: with: submodules: "recursive" + - name: Get version + uses: ./.github/actions/get-version + - name: Config Git safe dir run: git config --global --add safe.directory $GITHUB_WORKSPACE