From 039c7d4f060705d5c874abfd26a6ed4b00869555 Mon Sep 17 00:00:00 2001 From: Mattias Nordahl Date: Fri, 16 Aug 2024 12:07:11 +0200 Subject: [PATCH] Fix for workflow (2) --- .github/workflows/release.yml | 14 ++++++++------ release.sh | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f4fc55..76e36f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,16 +22,18 @@ jobs: - name: Set execute permissions for Gradle wrapper run: chmod +x ./gradlew + - name: Set TAG_NAME and JAR_NAME environment variable + run: | + echo "TAG_NAME=${GITHUB_REF#refs/tags/release_}" >> $GITHUB_ENV + echo "JAR_NAME=c3pu-$TAG_NAME.jar" >> $GITHUB_ENV + env: + GITHUB_REF: ${{ github.ref }} + - name: Build with Gradle run: ./gradlew build - name: Rename JAR File - run: | - TAG_NAME=${GITHUB_REF#refs/tags/release_} - JAR_NAME=c3pu-$TAG_NAME.jar - mv build/libs/c3pu-*.jar build/libs/$JAR_NAME - env: - GITHUB_REF: ${{ github.ref }} + run: mv build/libs/c3pu-*.jar build/libs/$JAR_NAME - name: Create Release id: create_release diff --git a/release.sh b/release.sh index bd73c2c..f8010c7 100644 --- a/release.sh +++ b/release.sh @@ -5,12 +5,13 @@ # workflow when a new tag is pushed, which will create a release on GitHub # using the tag. +# Usage: ./release ["Optional tag commit message"] # Check for the correct number of input parameters -if [ "$#" -ne 1 ]; then +if [ "$#" -lt 1 ]; then echo "Error: Incorrect number of arguments." - echo "Usage: $0 " - echo "Example: $0 v1.0.1" + echo "Usage: $0 [\"tag commit message\"]" + echo "Example: $0 v1.0.1 \"Initial release\"" exit 1 fi @@ -38,10 +39,15 @@ if git rev-parse "$TAG" >/dev/null 2>&1; then fi # Create the annotated tag -# git tag -a "$TAG" -m "$MESSAGE" -git tag -a "$TAG" +if [ -z "$2" ]; then + # If no message is provided, open the editor to allow the user to enter a message + git tag -a "$TAG" +else + # If a message is provided, use it directly + git tag -a "$TAG" -m "$2" +fi # Push the tag to the remote repository git push origin "$TAG" -echo "Tag $TAG created and pushed successfully." +echo "Tag $TAG created and pushed successfully." \ No newline at end of file