From 03c50fe09e3b7bba0dade09cfd7df5a64b3b8290 Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Mon, 11 Dec 2023 11:15:36 +0100 Subject: [PATCH] Sluggify branch/tag name Otherwise the zip step fails on branches/tags with "/" in it. --- .github/workflows/create-release-on-branch-changes.yml | 3 ++- .github/workflows/create-release-on-tag.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release-on-branch-changes.yml b/.github/workflows/create-release-on-branch-changes.yml index 31d9a66e1..c35578c69 100644 --- a/.github/workflows/create-release-on-branch-changes.yml +++ b/.github/workflows/create-release-on-branch-changes.yml @@ -20,13 +20,14 @@ jobs: # development. run: | RELEASE_BRANCH=$(echo ${GITHUB_REF#refs/heads/}) + RELEASE_BRANCH_SLUGGED=$(echo $RELEASE_BRANCH | sed -E -e 's/[^[:alnum:]]+/-/g' -e 's/^-+|-+$//g' | tr '[:upper:]' '[:lower:]') RELEASE_SHA=${{ github.sha }} TAG_NAME=$(echo "branch-${RELEASE_BRANCH}") echo "RELEASE_BRANCH=$RELEASE_BRANCH" >> "$GITHUB_ENV" echo "RELEASE_SHA=$RELEASE_SHA" >> "$GITHUB_ENV" echo "TAG_NAME=$TAG_NAME" >> "$GITHUB_ENV" echo "NPM_VERSION=0.0.0-${RELEASE_SHA}" >> "$GITHUB_ENV" - echo "DIST_FILENAME=dist-$RELEASE_BRANCH.zip" >> "$GITHUB_ENV" + echo "DIST_FILENAME=dist-${RELEASE_BRANCH_SLUGGED}.zip" >> "$GITHUB_ENV" # Checkout the HEAD of the PR branch to get the latest commit message. - uses: actions/checkout@v4 diff --git a/.github/workflows/create-release-on-tag.yml b/.github/workflows/create-release-on-tag.yml index 6d263d7d1..a3750a09f 100644 --- a/.github/workflows/create-release-on-tag.yml +++ b/.github/workflows/create-release-on-tag.yml @@ -14,11 +14,12 @@ jobs: id: resolve-release-vars run: | RELEASE_NAME=${{ github.ref_name }} + RELEASE_NAME_SLUGGED=$(echo $RELEASE_NAME | sed -E -e 's/[^[:alnum:]]+/-/g' -e 's/^-+|-+$//g' | tr '[:upper:]' '[:lower:]') RELEASE_SHA=${{ github.sha }} echo "RELEASE_NAME=$RELEASE_NAME" >> "$GITHUB_ENV" echo "RELEASE_SHA=$RELEASE_SHA" >> "$GITHUB_ENV" echo "NPM_VERSION=${RELEASE_NAME}-${RELEASE_SHA}" >> "$GITHUB_ENV" - echo "DIST_FILENAME=dist-$RELEASE_NAME-$RELEASE_SHA.zip" >> "$GITHUB_ENV" + echo "DIST_FILENAME=dist-${RELEASE_NAME_SLUGGED}-${RELEASE_SHA}.zip" >> "$GITHUB_ENV" # Validate/parse version tag. # If it is not a version tag it is ok, we just need to know it.