name: Release on: push: branches: - main # or your default branch jobs: release: runs-on: self-hosted steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 # fetch full history tags: true # fetch all tags - 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 - name: Build Artifacts if: steps.tag.outputs.version run: | chmod +x ./package ./package ls -l dist/ - 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 - 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 - name: Cleanup if: steps.tag.outputs.version run: rm -rf dist/*