diff --git a/.gitea/workflows/version.yml b/.gitea/workflows/version.yml index 085d1c7..afe01f4 100644 --- a/.gitea/workflows/version.yml +++ b/.gitea/workflows/version.yml @@ -65,6 +65,22 @@ jobs: git pull --rebase origin ${{ gitea.ref_name }} git push origin HEAD:${{ gitea.ref_name }} + - name: Create release + if: gitea.ref_name == 'main' + env: + TOKEN: ${{ gitea.token }} + TAG: v${{ steps.version.outputs.new }} + API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }} + run: | + status=$(curl -s -o /dev/null -w '%{http_code}' -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG") + if [ "$status" = "200" ]; then + echo "Release $TAG already exists, skipping" + exit 0 + fi + curl -sf -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \ + -d "{\"tag_name\": \"$TAG\", \"target_commitish\": \"$(git rev-parse HEAD)\", \"name\": \"$TAG\", \"body\": \"Release $TAG\"}" \ + "$API/releases" + - name: Merge main back into development if: gitea.ref_name == 'main' run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1cea647..1b036c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,3 +22,40 @@ jobs: # No linter or test suite is configured for this project yet. # This is a lightweight sanity check (syntax/import compile), not a test run. - run: python3 -m py_compile maskarr.py + + release: + needs: check + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # The version bump lands as a later "chore(release)" commit on main, so + # wait for it and release that commit instead of the pre-bump one. + - name: Resolve release commit + id: rel + run: | + sha="${{ github.sha }}" + for i in $(seq 1 30); do + git fetch -q origin main + bump=$(git log --reverse --format='%H %s' "$sha..origin/main" | grep -m1 ' chore(release): v' | cut -d' ' -f1 || true) + if [ -n "$bump" ]; then sha="$bump"; break; fi + sleep 20 + done + echo "sha=$sha" >> "$GITHUB_OUTPUT" + echo "version=$(git show "$sha:VERSION")" >> "$GITHUB_OUTPUT" + + - name: Create release + env: + GH_TOKEN: ${{ github.token }} + run: | + tag="v${{ steps.rel.outputs.version }}" + if gh release view "$tag" >/dev/null 2>&1; then + echo "Release $tag already exists, skipping" + else + gh release create "$tag" --target "${{ steps.rel.outputs.sha }}" --title "$tag" --generate-notes + fi diff --git a/CLAUDE.md b/CLAUDE.md index 1000fc1..1974bfb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -22,7 +22,7 @@ Everything lives in `maskarr.py`: an `http.server`-based proxy that forwards req - No `development` branch exists yet; CI and the version workflow reference it per the standard shape, but they won't trigger until it's created. ## Deployment -Docker image published to GHCR only, on push to `main`/tags (`.github/workflows/docker-publish.yml`). Version workflow lives in `.gitea/workflows/`; CI runs in both `.gitea/workflows/` and `.github/workflows/`. See `docs/deployment.md` for systemd and Docker instructions. +Docker image published to GHCR only, on push to `main`/tags (`.github/workflows/docker-publish.yml`). Version workflow lives in `.gitea/workflows/`; CI runs in both `.gitea/workflows/` and `.github/workflows/`. On pushes to `main`, a `vX.Y.Z` release is created on Gitea (last step of `version.yml`, after the bump) and on GitHub (`release` job in `.github/workflows/ci.yml`, which waits for the bump commit). See `docs/deployment.md` for systemd and Docker instructions. ## Gotchas - `maskarr_config.json` is tracked as an empty template; don't commit it populated with real tracker credentials/cookies. diff --git a/docs/deployment.md b/docs/deployment.md index c1ceadd..109a51d 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -81,6 +81,7 @@ docker run -d \ The GitHub Actions workflow `.github/workflows/docker-publish.yml` publishes the Docker image to **GitHub Container Registry** (`ghcr.io`) on each push to `main`/`master` or tag `v*.*.*`. CI and versioning run on Gitea Actions (`.gitea/workflows/` (CI also runs on GitHub)). +Every push to `main` creates a `vX.Y.Z` tag and release on both Gitea (`version.yml`, after the version bump) and GitHub (`release` job in `ci.yml`). ### Using published images