diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index edfeb1f..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: Release Workflow -on: [push] - -jobs: - release: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install zip - run: sudo apt-get install zip - - - name: Configure Git - run: | - git config --global user.name "Git Admin" - git config --global user.email "gitadmin@quack-lab.dev" - - - name: Run deploy script - run: bash deploy.sh - - - name: Check for Existing Release Commit - id: check_release_commit - run: | - # Check if the latest commit is a release commit - if git log -1 --pretty=%B | grep -q "Release"; then - echo "Release commit found. Skipping version bump." - echo "::set-output name=release_commit::true" - else - echo "No release commit found. Proceeding with version bump." - echo "::set-output name=release_commit::false" - fi - - - name: Run Release Script - if: steps.check_release_commit.outputs.release_commit == 'false' - run: bash release.sh - - - name: Push Changes - if: steps.check_release_commit.outputs.release_commit == 'false' - run: | - git push origin HEAD:refs/heads/master --tags - - - name: Determine Tag - id: determine_tag - run: | - # Check if the last commit has a tag - TAG=$(git describe --tags --exact-match 2>/dev/null || echo "") - if [ -z "$TAG" ]; then - # Get the latest tag - LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) - # Increment the minor version - IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG" - VERSION_PARTS[2]=$((VERSION_PARTS[2]+1)) - TAG="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}" - # Create a new tag - git tag $TAG - git push origin $TAG - fi - echo "::set-output name=tag::$TAG" - - - name: Create Release - id: create_release - run: | - curl -X POST \ - -H "Authorization: token ${{ secrets.JEBENI_TOKEN }}" \ - -H "Accept: application/json" \ - -H "Content-Type: application/json" \ - -d '{ - "tag_name": "${{ steps.determine_tag.outputs.tag }}", - "name": "${{ steps.determine_tag.outputs.tag }}", - "draft": false, - "prerelease": false - }' \ - http://srv-captain--git:3000/api/v1/repos/dave/wow-Heimdall/releases - - - name: Upload Release Asset - run: | - RELEASE_ID=$(curl -s \ - -H "Authorization: token ${{ secrets.JEBENI_TOKEN }}" \ - http://srv-captain--git:3000/api/v1/repos/dave/wow-Heimdall/releases/tags/${{ steps.determine_tag.outputs.tag }} | jq -r '.id') - curl -X POST \ - -H "Authorization: token ${{ secrets.JEBENI_TOKEN }}" \ - -F "attachment=@Heimdall.zip" \ - "http://srv-captain--git:3000/api/v1/repos/dave/wow-Heimdall/releases/${RELEASE_ID}/assets?name=Heimdall.zip" diff --git a/release.sh b/release.sh index d516195..1a846da 100644 --- a/release.sh +++ b/release.sh @@ -1,43 +1,58 @@ #!/bin/bash -# Default version increment -DEFAULT_INCREMENT="0.0.1" +echo "Figuring out the tag..." +TAG=$(git describe --tags --exact-match 2>/dev/null || echo "") +if [ -z "$TAG" ]; then + # Get the latest tag + LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) + # Increment the patch version + IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG" + VERSION_PARTS[2]=$((VERSION_PARTS[2]+1)) + TAG="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}" + # Create a new tag + git tag $TAG + git push origin $TAG +fi +echo "Tag: $TAG" -# Get the increment parameter or use the default -INCREMENT=${1:-$DEFAULT_INCREMENT} - -# Function to increment the version -increment_version() { - local version=$1 - local increment=$2 - - IFS='.' read -r -a version_parts <<< "$version" - IFS='.' read -r -a increment_parts <<< "$increment" - - # Increment major, minor, and patch - version_parts[0]=$((version_parts[0] + increment_parts[0])) - version_parts[1]=$((version_parts[1] + increment_parts[1])) - version_parts[2]=$((version_parts[2] + increment_parts[2])) - - # Reset minor and patch if major is incremented - if [ "${increment_parts[0]}" -gt 0 ]; then - version_parts[1]=0 - version_parts[2]=0 - elif [ "${increment_parts[1]}" -gt 0 ]; then - version_parts[2]=0 - fi - - echo "${version_parts[0]}.${version_parts[1]}.${version_parts[2]}" -} - -CURRENT_VERSION=$(grep -oP '## Version: \K[0-9]+\.[0-9]+\.[0-9]+' Heimdall.toc) -NEW_VERSION=$(increment_version "$CURRENT_VERSION" "$INCREMENT") +echo "Building the thing..." sed -i "s/## Version: $CURRENT_VERSION/## Version: $NEW_VERSION/" Heimdall.toc sed -i "s/local VERSION = \"$CURRENT_VERSION\"/local VERSION = \"$NEW_VERSION\"/" Heimdall.lua -# Git operations -git add Heimdall.lua Heimdall.toc -git commit -m "Release $NEW_VERSION" -git tag "$NEW_VERSION" +rm Heimdall-${TAG}.zip +mkdir Heimdall +cp *.lua *.toc Heimdall +cp -r Modules Heimdall +cp -r Sounds Heimdall +cp -r Texture Heimdall +zip -r Heimdall-${TAG}.zip Heimdall +rm -rf Heimdall -echo "Deployment complete. New version: $NEW_VERSION" \ No newline at end of file +echo "Creating a release..." +TOKEN="$GITEA_API_KEY" +GITEA="https://git.site.quack-lab.dev" +REPO="dave/wow-heimdall" +# Create a release +RELEASE_RESPONSE=$(curl -s -X POST \ + -H "Authorization: token $TOKEN" \ + -H "Accept: application/json" \ + -H "Content-Type: application/json" \ + -d '{ + "tag_name": "'"$TAG"'", + "name": "'"$TAG"'", + "draft": false, + "prerelease": false + }' \ + $GITEA/api/v1/repos/$REPO/releases) + +# Extract the release ID +echo $RELEASE_RESPONSE +RELEASE_ID=$(echo $RELEASE_RESPONSE | awk -F'"id":' '{print $2+0; exit}') +echo "Release ID: $RELEASE_ID" + +echo "Uploading the things..." +curl -X POST \ + -H "Authorization: token $TOKEN" \ + -F "attachment=@Heimdall-${TAG}.zip" \ + "$GITEA/api/v1/repos/$REPO/releases/${RELEASE_ID}/assets?name=Heimdall-${TAG}.zip" +rm Heimdall-${TAG}.zip