diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f80552c..d88fecc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,10 @@ on: permissions: contents: write +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: true + jobs: validate-release: name: Validate Release @@ -22,12 +26,11 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | version="$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")" - if [ "${{ github.ref }}" = "refs/heads/main" ]; then - tag="v${version}" - else - safe_ref="$(echo "${{ github.ref_name }}" | tr '/_' '--' | tr -cd '[:alnum:].-')" - tag="v${version}-${safe_ref}.${GITHUB_RUN_NUMBER}" + if [ "${{ github.ref }}" != "refs/heads/main" ]; then + echo "Development release dev-v${version} will be created or updated." + exit 0 fi + tag="v${version}" if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then echo "::error title=Release tag already exists::${tag} already exists. Bump project.version in pyproject.toml before running the release workflow." @@ -167,8 +170,7 @@ jobs: if [ "${{ github.ref }}" = "refs/heads/main" ]; then tag="v${version}" else - safe_ref="$(echo "${{ github.ref_name }}" | tr '/_' '--' | tr -cd '[:alnum:].-')" - tag="v${version}-${safe_ref}.${GITHUB_RUN_NUMBER}" + tag="dev-v${version}" fi repo_url="${{ github.server_url }}/${{ github.repository }}" previous_tag="$(git tag --merged HEAD --sort=-v:refname | grep -E '^v[0-9]+(\.[0-9]+)*$' | grep -vx "$tag" | head -n 1 || true)" @@ -223,11 +225,10 @@ jobs: version="${{ steps.package-version.outputs.version }}" if [ "${{ github.ref }}" = "refs/heads/main" ]; then tag="v${version}" - prerelease_args=() + title="v${version} Release" else - safe_ref="$(echo "${{ github.ref_name }}" | tr '/_' '--' | tr -cd '[:alnum:].-')" - tag="v${version}-${safe_ref}.${GITHUB_RUN_NUMBER}" - prerelease_args=(--prerelease) + tag="dev-v${version}" + title="v${version} Development Build" fi files=( nte-history-exporter.exe @@ -238,14 +239,30 @@ jobs: nte-history-exporter-v${version}-x86_64-apple-darwin.zip ) - if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then - echo "::error title=Release tag already exists::${tag} already exists. Bump project.version in pyproject.toml before running the release workflow." - exit 1 + if [ "${{ github.ref }}" = "refs/heads/main" ]; then + if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then + echo "::error title=Release tag already exists::${tag} already exists. Bump project.version in pyproject.toml before running the release workflow." + exit 1 + fi + + if gh release view "$tag" >/dev/null 2>&1; then + echo "::error title=GitHub release already exists::${tag} already has a GitHub release. Bump project.version in pyproject.toml before running the release workflow." + exit 1 + fi + + gh release create "$tag" "${files[@]}" --title "$title" --notes-file release-notes.md + exit 0 fi + # Development releases are intentionally mutable. Keep one prerelease + # per package version and move it to the commit that produced the + # latest successful build. + git tag --force "$tag" "$GITHUB_SHA" + git push origin "refs/tags/${tag}" --force + if gh release view "$tag" >/dev/null 2>&1; then - echo "::error title=GitHub release already exists::${tag} already has a GitHub release. Bump project.version in pyproject.toml before running the release workflow." - exit 1 + gh release edit "$tag" --title "$title" --notes-file release-notes.md --prerelease + gh release upload "$tag" "${files[@]}" --clobber + else + gh release create "$tag" "${files[@]}" --title "$title" --notes-file release-notes.md --prerelease fi - - gh release create "$tag" "${files[@]}" --title "${tag} Release" --notes-file release-notes.md "${prerelease_args[@]}" diff --git a/docs/export-format.md b/docs/export-format.md index 1b9ea37..863442f 100644 --- a/docs/export-format.md +++ b/docs/export-format.md @@ -15,7 +15,7 @@ decoder-only offsets. "capture_source": "npcap", "exporter": { "name": "nte-history-exporter", - "version": "0.1.12" + "version": "0.2.0" }, "banner": { "id": "Lottery_Permanent", diff --git a/pyproject.toml b/pyproject.toml index f87550c..39e30a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nte-history-exporter" -version = "0.1.12" +version = "0.2.0" description = "Cross-platform Neverness to Everness pull-history exporter." requires-python = ">=3.10" dependencies = [] diff --git a/src/nte_history_exporter/__init__.py b/src/nte_history_exporter/__init__.py index 74acd0e..d3ec452 100644 --- a/src/nte_history_exporter/__init__.py +++ b/src/nte_history_exporter/__init__.py @@ -1 +1 @@ -__version__ = "0.1.12" +__version__ = "0.2.0" diff --git a/src/nte_history_exporter/constants.py b/src/nte_history_exporter/constants.py index 0491f89..f5afd5b 100644 --- a/src/nte_history_exporter/constants.py +++ b/src/nte_history_exporter/constants.py @@ -13,7 +13,7 @@ ARC_BANNER_NAME = "Arc Miracle Box" MYSTERY_BOX_BANNER_ID = "Gashapon_MysteryBox" MYSTERY_BOX_BANNER_NAME = "Mystery Box" EXPORTER_NAME = "nte-history-exporter" -EXPORTER_VERSION = "0.1.12" +EXPORTER_VERSION = "0.2.0" HISTORY_REQUEST_BANNER = 4220 HISTORY_REQUEST_LENGTH = 45