From 3aa792a620209bbbb4396e4db25c4ebe5c662ce1 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 8 Mar 2026 23:34:09 +0000 Subject: [PATCH] Add release workflow --- .gitea/workflows/release.yml | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..bcdf8e5 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,84 @@ +name: Release + +on: + push: + branches: + - main # or your default branch + +jobs: + release: + runs-on: self-hosted + + steps: + # 1. Checkout repository + - name: Checkout repository + uses: actions/checkout@v4 + + # 2. Read VERSION file and check if tag exists + - name: Check/Create Tag + id: tag + run: | + VERSION=$(cat VERSION | tr -d '[:space:]') # read version and trim whitespace + echo "Version: $VERSION" + + if git rev-parse "v$VERSION" >/dev/null 2>&1; then + echo "Tag v$VERSION already exists. Skipping release." + exit 0 + fi + + # Tag does not exist → create it + echo "Creating tag v$VERSION" + git tag "v$VERSION" + git push origin "v$VERSION" + + echo "version=$VERSION" >> $GITHUB_OUTPUT + + # 3. Build artifacts (only runs if tag did not exist) + - name: Build Artifacts + if: steps.tag.outputs.version + run: | + chmod +x ./package + ./package + ls -l dist/ + + # 4. Create release + - name: Create Release + if: steps.tag.outputs.version + id: create_release + run: | + VERSION="${{ steps.tag.outputs.version }}" + RESPONSE=$(curl -s -X POST \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -H "Content-Type: application/json" \ + "https://git.thewizardapprentice.com/api/v1/repos/${{ gitea.repository }}/releases" \ + -d '{ + "tag_name": "v'"$VERSION"'", + "name": "wapp-v'"$VERSION"'", + "body": "Automated release for wapp-v'"$VERSION"'", + "draft": false, + "prerelease": false + }') + + echo "$RESPONSE" + RELEASE_ID=$(echo $RESPONSE | jq -r '.id') + echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT + + # 5. Upload artifacts + - name: Upload Artifacts + if: steps.tag.outputs.version + run: | + RELEASE_ID="${{ steps.create_release.outputs.release_id }}" + for FILE in dist/*; do + FILENAME=$(basename "$FILE") + echo "Uploading $FILENAME" + curl -X POST \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @"$FILE" \ + "https://git.thewizardapprentice.com/api/v1/repos/${{ gitea.repository }}/releases/$RELEASE_ID/assets?name=$FILENAME" + done + + # 6. Cleanup artifacts + - name: Cleanup + if: steps.tag.outputs.version + run: rm -rf dist/*