name: Release on: push: branches: [main] jobs: bump-version: name: Bump version and tag # Skip if this is a version-bump commit (avoid infinite loop) if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Configure git run: | git config user.name "Gitea Actions" git config user.email "actions@gitea.local" - name: Bump patch version run: | # Read current version from package.json CURRENT=$(grep '"version"' package.json | head -1 | sed 's/.*"version": *"\([^"]*\)".*/\1/') echo "Current version: ${CURRENT}" # Increment patch number MAJOR=$(echo "${CURRENT}" | cut -d. -f1) MINOR=$(echo "${CURRENT}" | cut -d. -f2) PATCH=$(echo "${CURRENT}" | cut -d. -f3) NEW_PATCH=$((PATCH + 1)) NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}" echo "New version: ${NEW_VERSION}" # Update package.json sed -i "s/\"version\": \"${CURRENT}\"/\"version\": \"${NEW_VERSION}\"/" package.json # Update src-tauri/tauri.conf.json sed -i "s/\"version\": \"${CURRENT}\"/\"version\": \"${NEW_VERSION}\"/" src-tauri/tauri.conf.json # Update src-tauri/Cargo.toml (match version = "x.y.z" in [package] section) sed -i "s/^version = \"${CURRENT}\"/version = \"${NEW_VERSION}\"/" src-tauri/Cargo.toml # Update python/pyproject.toml sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" python/pyproject.toml echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV - name: Commit and tag env: BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }} run: | git add package.json src-tauri/tauri.conf.json src-tauri/Cargo.toml python/pyproject.toml git commit -m "chore: bump version to ${NEW_VERSION} [skip ci]" git tag "v${NEW_VERSION}" # Push using token for authentication REMOTE_URL=$(git remote get-url origin | sed "s|://|://gitea-actions:${BUILD_TOKEN}@|") git push "${REMOTE_URL}" HEAD:main git push "${REMOTE_URL}" "v${NEW_VERSION}" - name: Create Gitea release env: BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }} run: | REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" TAG="v${NEW_VERSION}" RELEASE_NAME="Voice to Notes ${TAG}" curl -s -X POST \ -H "Authorization: token ${BUILD_TOKEN}" \ -H "Content-Type: application/json" \ -d "{\"tag_name\": \"${TAG}\", \"name\": \"${RELEASE_NAME}\", \"body\": \"Automated build.\", \"draft\": false, \"prerelease\": false}" \ "${REPO_API}/releases" echo "Created release: ${RELEASE_NAME}"