From c8984cc2272dacde9e69bce9692c27a50c3974fa Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Fri, 10 Mar 2023 17:42:19 +0100
Subject: [PATCH] Fix workflows

---
 .github/workflows/build-release.yml | 18 ++++++++++++------
 .github/workflows/php.yml           |  6 ++++++
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml
index c9eb10ea3..c039fff41 100644
--- a/.github/workflows/build-release.yml
+++ b/.github/workflows/build-release.yml
@@ -24,13 +24,19 @@ jobs:
       - name: Setup problem matchers for PHP
         run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
 
+      # Store the version, stripping any v-prefix
+      - name: Write release version
+        run: |
+          TAG=${{ github.ref_name }}
+          echo "VERSION=${TAG#v}" >> $GITHUB_ENV
+
       - uses: actions/checkout@v3
 
       - name: Validate composer.json and composer.lock
         run: composer validate
 
       - name: Set version in composer.json
-        run: composer config version "${{ github.ref_name }}"
+        run: composer config version "$VERSION"
 
       - name: Install Composer dependencies
         run: composer install --no-progress --no-dev --prefer-dist --optimize-autoloader
@@ -46,16 +52,16 @@ jobs:
       - name: Build tarball
         run: |
           cd ..
-          cp -R  simplesamlphp "simplesamlphp-${{ github.ref_name }}"
-          tar --owner 0 --group 0 -cvzf "/tmp/simplesamlphp-${{ github.ref_name }}.tar.gz" \
-          "simplesamlphp-${{ github.ref_name }}"
+          cp -R  simplesamlphp "simplesamlphp-$VERSION"
+          tar --owner 0 --group 0 -cvzf "/tmp/simplesamlphp-$VERSION.tar.gz" \
+          "simplesamlphp-$VERSION"
 
       - name: Save tarball
         uses: actions/upload-artifact@v3
         with:
           name: release
-          path: "/tmp/simplesamlphp-${{ github.ref_name }}.tar.gz"
+          path: "/tmp/simplesamlphp-$VERSION.tar.gz"
           retention-days: 1
 
       - name: Calculate SHA checksum
-        run: sha256sum "/tmp/simplesamlphp-${{ github.ref_name }}.tar.gz"
+        run: sha256sum "/tmp/simplesamlphp-$VERSION.tar.gz"
diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index 008cb2a0c..d654bb6df 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -53,6 +53,9 @@ jobs:
 
       - uses: actions/checkout@v3
 
+      - name: Get composer cache directory
+        run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
+
       - name: Cache composer dependencies
         uses: actions/cache@v3
         with:
@@ -111,6 +114,9 @@ jobs:
 
       - uses: actions/checkout@v3
 
+      - name: Get composer cache directory
+        run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"
+
       - name: Cache composer dependencies
         uses: actions/cache@v3
         with:
-- 
GitLab