docs: add release fallback logic and troubleshooting section

Add ::warning:: annotation and fallback to fetch existing release
when tag already has a release. Add troubleshooting section for
re-triggering failed release workflows. Fix markdown lint warnings.
This commit is contained in:
2026-03-23 02:47:57 +03:00
parent f22e3fabe6
commit f17ff30c11

View File

@@ -12,7 +12,7 @@ A reusable reference for building CI pipelines, release automation, and installe
Two workflows, triggered by different events: Two workflows, triggered by different events:
``` ```text
push/PR to master ──► test.yml (lint + test) push/PR to master ──► test.yml (lint + test)
push tag v* ──► release.yml (build + release + Docker) push tag v* ──► release.yml (build + release + Docker)
``` ```
@@ -127,7 +127,14 @@ create-release:
\"prerelease\": \$IS_PRE \"prerelease\": \$IS_PRE
}") }")
# Fallback: if release already exists for this tag, fetch it instead
RELEASE_ID=$(echo "\$RELEASE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])" 2>/dev/null)
if [ -z "\$RELEASE_ID" ]; then
echo "::warning::Release already exists for tag \$TAG — reusing existing release"
RELEASE=$(curl -s "\$BASE_URL/releases/tags/\$TAG" \
-H "Authorization: token \$GITEA_TOKEN")
RELEASE_ID=$(echo "\$RELEASE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") RELEASE_ID=$(echo "\$RELEASE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
fi
echo "release_id=\$RELEASE_ID" >> "\$GITHUB_OUTPUT" echo "release_id=\$RELEASE_ID" >> "\$GITHUB_OUTPUT"
``` ```
@@ -409,7 +416,7 @@ CMD ["uvicorn", "your_package.main:app", "--host", "0.0.0.0", "--port", "8080"]
## 8. Release Versioning ## 8. Release Versioning
| Tag format | Example | Pre-release? | Docker `:latest`? | | Tag format | Example | Pre-release? | Docker `:latest`? |
|---|---|---|---| | --- | --- | --- | --- |
| `v{major}.{minor}.{patch}` | `v0.2.0` | No | Yes | | `v{major}.{minor}.{patch}` | `v0.2.0` | No | Yes |
| `v{major}.{minor}.{patch}-alpha.{n}` | `v0.2.0-alpha.1` | Yes | No | | `v{major}.{minor}.{patch}-alpha.{n}` | `v0.2.0-alpha.1` | Yes | No |
| `v{major}.{minor}.{patch}-beta.{n}` | `v0.2.0-beta.2` | Yes | No | | `v{major}.{minor}.{patch}-beta.{n}` | `v0.2.0-beta.2` | Yes | No |
@@ -430,7 +437,7 @@ git push origin v0.2.0-alpha.1
## 9. Gitea vs GitHub Actions Differences ## 9. Gitea vs GitHub Actions Differences
| Feature | GitHub Actions | Gitea Actions | | Feature | GitHub Actions | Gitea Actions |
|---|---|---| | --- | --- | --- |
| Context prefix | `github.*` | `gitea.*` | | Context prefix | `github.*` | `gitea.*` |
| Ref name | `${{ github.ref_name }}` | `${{ gitea.ref_name }}` | | Ref name | `${{ github.ref_name }}` | `${{ gitea.ref_name }}` |
| Server URL | `${{ github.server_url }}` | `${{ gitea.server_url }}` | | Server URL | `${{ github.server_url }}` | `${{ gitea.server_url }}` |
@@ -453,3 +460,28 @@ git push origin v0.2.0-alpha.1
- [ ] Create `Dockerfile` for Docker builds (optional) - [ ] Create `Dockerfile` for Docker builds (optional)
- [ ] Configure `pyproject.toml` with `[tool.ruff]` and `[tool.pytest]` - [ ] Configure `pyproject.toml` with `[tool.ruff]` and `[tool.pytest]`
- [ ] Set up `.pre-commit-config.yaml` with ruff + black - [ ] Set up `.pre-commit-config.yaml` with ruff + black
## 11. Troubleshooting
### Release already exists for tag
If the `create-release` job fails with `KeyError: 'id'`, the Gitea API returned an error
because a release already exists for that tag (e.g., from a previous failed run).
**Prevention:** The fallback logic in section 2.1 handles this automatically — if creation
fails, it fetches the existing release by tag and reuses its ID. A `::warning::` annotation
is emitted in the workflow log.
**Re-triggering a failed release workflow:**
```bash
# Option A: Delete and re-push the same tag
git push origin :refs/tags/v0.1.0-alpha.2 # delete remote tag
# Delete the release in Gitea UI or via API
git tag -f v0.1.0-alpha.2 # recreate local tag
git push origin v0.1.0-alpha.2 # push again
# Option B: Just bump the version (simpler)
git tag v0.1.0-alpha.3
git push origin v0.1.0-alpha.3
```