Fix up the release to be a little more manual
This commit is contained in:
86
.github/workflows/release.yml
vendored
86
.github/workflows/release.yml
vendored
@@ -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"
|
|
85
release.sh
85
release.sh
@@ -1,43 +1,58 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Default version increment
|
echo "Figuring out the tag..."
|
||||||
DEFAULT_INCREMENT="0.0.1"
|
TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
|
||||||
|
if [ -z "$TAG" ]; then
|
||||||
# Get the increment parameter or use the default
|
# Get the latest tag
|
||||||
INCREMENT=${1:-$DEFAULT_INCREMENT}
|
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
|
||||||
|
# Increment the patch version
|
||||||
# Function to increment the version
|
IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG"
|
||||||
increment_version() {
|
VERSION_PARTS[2]=$((VERSION_PARTS[2]+1))
|
||||||
local version=$1
|
TAG="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
|
||||||
local increment=$2
|
# Create a new tag
|
||||||
|
git tag $TAG
|
||||||
IFS='.' read -r -a version_parts <<< "$version"
|
git push origin $TAG
|
||||||
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
|
fi
|
||||||
|
echo "Tag: $TAG"
|
||||||
|
|
||||||
echo "${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
|
echo "Building the thing..."
|
||||||
}
|
|
||||||
|
|
||||||
CURRENT_VERSION=$(grep -oP '## Version: \K[0-9]+\.[0-9]+\.[0-9]+' Heimdall.toc)
|
|
||||||
NEW_VERSION=$(increment_version "$CURRENT_VERSION" "$INCREMENT")
|
|
||||||
sed -i "s/## Version: $CURRENT_VERSION/## Version: $NEW_VERSION/" Heimdall.toc
|
sed -i "s/## Version: $CURRENT_VERSION/## Version: $NEW_VERSION/" Heimdall.toc
|
||||||
sed -i "s/local VERSION = \"$CURRENT_VERSION\"/local VERSION = \"$NEW_VERSION\"/" Heimdall.lua
|
sed -i "s/local VERSION = \"$CURRENT_VERSION\"/local VERSION = \"$NEW_VERSION\"/" Heimdall.lua
|
||||||
|
|
||||||
# Git operations
|
rm Heimdall-${TAG}.zip
|
||||||
git add Heimdall.lua Heimdall.toc
|
mkdir Heimdall
|
||||||
git commit -m "Release $NEW_VERSION"
|
cp *.lua *.toc Heimdall
|
||||||
git tag "$NEW_VERSION"
|
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"
|
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
|
||||||
|
Reference in New Issue
Block a user