Skip to content

Commit

Permalink
Fix for workflow (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnordahl committed Aug 16, 2024
1 parent 88a40af commit 039c7d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
# workflow when a new tag is pushed, which will create a release on GitHub
# using the tag.

# Usage: ./release <version-number> ["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 <version-number>"
echo "Example: $0 v1.0.1"
echo "Usage: $0 <version-number> [\"tag commit message\"]"
echo "Example: $0 v1.0.1 \"Initial release\""
exit 1
fi

Expand Down Expand Up @@ -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."

0 comments on commit 039c7d4

Please sign in to comment.