This is an automated email from the ASF dual-hosted git repository.
hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin.git
The following commit(s) were added to refs/heads/master by this push:
new 6259f03 ci: publish releases from manually pushed tags
6259f03 is described below
commit 6259f0370a7df23ace90d10c43bf0866fb5185fb
Author: Yang Luo <[email protected]>
AuthorDate: Tue Aug 4 00:31:01 2026 +0800
ci: publish releases from manually pushed tags
---
.github/workflows/release.yml | 204 +++++++++++++++++++++++++++++
.github/workflows/source-release-draft.yml | 137 -------------------
2 files changed, 204 insertions(+), 137 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..028400f
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,204 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Releases are driven by manually pushed tags only. Nothing is published
+# automatically when a pull request is merged.
+#
+# v<X>.<Y>.<Z>-rc<N> GitHub pre-release only.
+# v<X>.<Y>.<Z> GitHub release plus the Go module proxy.
+
+name: Release
+
+on:
+ push:
+ tags:
+ - "v*"
+
+permissions:
+ contents: write
+
+jobs:
+ release:
+ if: ${{ github.repository == 'apache/casbin' }}
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Compute release metadata
+ id: release
+ run: |
+ set -euo pipefail
+
+ TAG_NAME="${GITHUB_REF_NAME}"
+ if [[ "${TAG_NAME}" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
+ IS_RC="false"
+ elif [[ "${TAG_NAME}" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)-rc[0-9]+$ ]];
then
+ IS_RC="true"
+ else
+ echo "::error::Unsupported release tag: ${TAG_NAME}. Expected
vX.Y.Z or vX.Y.Z-rcN."
+ exit 1
+ fi
+
+ VERSION="${BASH_REMATCH[1]}"
+ BASENAME="apache-casbin-incubating-${VERSION}-src"
+
+ # Previous release, used as the start of the change log range.
+ PREVIOUS_TAG="$(
+ {
+ git tag --list 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true
+ echo "v${VERSION}"
+ } |
+ sort -V -u |
+ awk -v current="v${VERSION}" '
+ $0 == current {
+ print previous
+ exit
+ }
+ {
+ previous = $0
+ }
+ '
+ )"
+
+ {
+ echo "tag=${TAG_NAME}"
+ echo "version=${VERSION}"
+ echo "is_rc=${IS_RC}"
+ echo "basename=${BASENAME}"
+ echo "previous_tag=${PREVIOUS_TAG}"
+ } >> "${GITHUB_OUTPUT}"
+
+ - name: Generate release notes
+ run: |
+ set -euo pipefail
+
+ CURRENT_TAG="${{ steps.release.outputs.tag }}"
+ CURRENT_VERSION="${CURRENT_TAG#v}"
+ PREVIOUS_TAG="${{ steps.release.outputs.previous_tag }}"
+ RELEASE_DATE="$(date -u +%F)"
+ RANGE="${CURRENT_TAG}"
+
+ if [ -n "${PREVIOUS_TAG}" ]; then
+ RANGE="${PREVIOUS_TAG}..${CURRENT_TAG}"
+ fi
+
+ FEATURES="$(git log --pretty=format:'%s (%h)' "${RANGE}" | grep -Ei
'^(feat)(\(.+\))?: ' || true)"
+ FIXES="$(git log --pretty=format:'%s (%h)' "${RANGE}" | grep -Ei
'^(fix)(\(.+\))?: ' || true)"
+ DOCS="$(git log --pretty=format:'%s (%h)' "${RANGE}" | grep -Ei
'^(docs?|doc)(\(.+\))?: ' || true)"
+
+ {
+ if [ -n "${PREVIOUS_TAG}" ]; then
+ echo "#
[${CURRENT_VERSION}](https://github.com/${GITHUB_REPOSITORY}/compare/${PREVIOUS_TAG}...${CURRENT_TAG})
(${RELEASE_DATE})"
+ else
+ echo "# ${CURRENT_VERSION} (${RELEASE_DATE})"
+ fi
+ echo
+ if [ "${{ steps.release.outputs.is_rc }}" = "true" ]; then
+ echo "Release candidate for ${{ steps.release.outputs.version
}}. This is not an official release."
+ echo
+ fi
+
+ if [ -n "${FEATURES}" ]; then
+ echo "## Features"
+ echo
+ printf '%s\n' "${FEATURES}" | sed 's/^/- /'
+ echo
+ fi
+
+ if [ -n "${FIXES}" ]; then
+ echo "## Fixes"
+ echo
+ printf '%s\n' "${FIXES}" | sed 's/^/- /'
+ echo
+ fi
+
+ if [ -n "${DOCS}" ]; then
+ echo "## Docs"
+ echo
+ printf '%s\n' "${DOCS}" | sed 's/^/- /'
+ echo
+ fi
+
+ if [ -z "${FEATURES}${FIXES}${DOCS}" ]; then
+ echo "## Notes"
+ echo
+ echo "- No feat/fix/doc commits were found in this release
range."
+ fi
+ } > RELEASE_NOTES.md
+
+ - name: Create source archives
+ run: |
+ set -euo pipefail
+
+ BASENAME="${{ steps.release.outputs.basename }}"
+ mkdir -p dist
+ git archive --format=tar.gz --prefix="${BASENAME}/" -o
"dist/${BASENAME}.tar.gz" "${{ steps.release.outputs.tag }}"
+ git archive --format=zip --prefix="${BASENAME}/" -o
"dist/${BASENAME}.zip" "${{ steps.release.outputs.tag }}"
+
+ cd dist
+ for archive in "${BASENAME}.tar.gz" "${BASENAME}.zip"; do
+ sha512sum "${archive}" > "${archive}.sha512"
+ done
+ sha512sum --check ./*.sha512
+
+ - name: Publish GitHub release
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+
+ if [ "${{ steps.release.outputs.is_rc }}" = "true" ]; then
+ TITLE="Apache Casbin (Incubating) ${{
steps.release.outputs.version }} (release candidate ${{
steps.release.outputs.tag }})"
+ FLAGS=(--prerelease)
+ else
+ TITLE="Apache Casbin (Incubating) ${{
steps.release.outputs.version }}"
+ FLAGS=(--latest)
+ fi
+
+ gh release create "${{ steps.release.outputs.tag }}" \
+ --verify-tag \
+ --title "${TITLE}" \
+ --notes-file RELEASE_NOTES.md \
+ "${FLAGS[@]}" \
+ dist/*
+
+ - name: Publish to the Go module proxy
+ if: ${{ steps.release.outputs.is_rc == 'false' }}
+ run: |
+ set -euo pipefail
+
+ MODULE_PATH="$(awk '/^module /{print $2; exit}' go.mod)"
+ TAG="${{ steps.release.outputs.tag }}"
+
+ # Requesting the version makes the proxy fetch and cache it, which is
+ # what publishes the release to the Go module ecosystem.
+ for attempt in 1 2 3; do
+ if curl --fail --silent --show-error --location \
+ "https://proxy.golang.org/${MODULE_PATH}/@v/${TAG}.info"; then
+ echo
+ echo "Published ${MODULE_PATH}@${TAG} to proxy.golang.org."
+ exit 0
+ fi
+ echo "Attempt ${attempt} failed, retrying in 30s..."
+ sleep 30
+ done
+
+ echo "::error::Failed to publish ${MODULE_PATH}@${TAG} to
proxy.golang.org."
+ exit 1
diff --git a/.github/workflows/source-release-draft.yml
b/.github/workflows/source-release-draft.yml
deleted file mode 100644
index 5caa3f7..0000000
--- a/.github/workflows/source-release-draft.yml
+++ /dev/null
@@ -1,137 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-name: Build Source Release Draft
-
-on:
- push:
- tags:
- - "v*"
-
-permissions:
- contents: write
-
-jobs:
- build-source-release-draft:
- if: ${{ github.repository == 'apache/casbin' && !contains(github.ref_name,
'-') }}
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Compute release metadata
- id: release
- run: |
- TAG_NAME="${GITHUB_REF_NAME}"
- if ! [[ "${TAG_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
- echo "Unsupported release tag: ${TAG_NAME}" >&2
- exit 1
- fi
-
- VERSION="${TAG_NAME#v}"
- BASENAME="casbin-${VERSION}-src"
- PREVIOUS_TAG="$(
- git tag --list 'v*' |
- grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' |
- sort -V |
- awk -v current="${TAG_NAME}" '
- $0 == current {
- print previous
- exit
- }
- {
- previous = $0
- }
- '
- )"
-
- echo "tag=${TAG_NAME}" >> "${GITHUB_OUTPUT}"
- echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
- echo "basename=${BASENAME}" >> "${GITHUB_OUTPUT}"
- echo "previous_tag=${PREVIOUS_TAG}" >> "${GITHUB_OUTPUT}"
-
- - name: Generate release notes
- run: |
- CURRENT_TAG="${{ steps.release.outputs.tag }}"
- CURRENT_VERSION="${CURRENT_TAG#v}"
- PREVIOUS_TAG="${{ steps.release.outputs.previous_tag }}"
- RELEASE_DATE="$(date -u +%F)"
- RANGE="${CURRENT_TAG}"
-
- if [ -n "${PREVIOUS_TAG}" ]; then
- RANGE="${PREVIOUS_TAG}..${CURRENT_TAG}"
- fi
-
- FEATURES="$(git log --pretty=format:'%s (%h)' "${RANGE}" | grep -Ei
'^(feat)(\(.+\))?: ' || true)"
- FIXES="$(git log --pretty=format:'%s (%h)' "${RANGE}" | grep -Ei
'^(fix)(\(.+\))?: ' || true)"
- DOCS="$(git log --pretty=format:'%s (%h)' "${RANGE}" | grep -Ei
'^(docs?|doc)(\(.+\))?: ' || true)"
-
- {
- if [ -n "${PREVIOUS_TAG}" ]; then
- echo "#
[${CURRENT_VERSION}](https://github.com/${GITHUB_REPOSITORY}/compare/${PREVIOUS_TAG}...${CURRENT_TAG})
(${RELEASE_DATE})"
- else
- echo "# ${CURRENT_VERSION} (${RELEASE_DATE})"
- fi
- echo
- echo "This GitHub release is a draft helper for packaging and
release notes."
- echo
- if [ -n "${FEATURES}" ]; then
- echo "## Features"
- echo
- printf '%s\n' "${FEATURES}" | sed 's/^/- /'
- echo
- fi
-
- if [ -n "${FIXES}" ]; then
- echo "## Fixes"
- echo
- printf '%s\n' "${FIXES}" | sed 's/^/- /'
- echo
- fi
-
- if [ -n "${DOCS}" ]; then
- echo "## Docs"
- echo
- printf '%s\n' "${DOCS}" | sed 's/^/- /'
- echo
- fi
-
- if [ -z "${FEATURES}${FIXES}${DOCS}" ]; then
- echo "## Notes"
- echo
- echo "- No feat/fix/doc commits were found in this release
range."
- fi
- } > RELEASE_NOTES.md
-
- - name: Create source archives
- run: |
- mkdir -p dist
- git archive --format=tar.gz --prefix="${{
steps.release.outputs.basename }}/" -o "dist/${{ steps.release.outputs.basename
}}.tar.gz" "${{ steps.release.outputs.tag }}"
- git archive --format=zip --prefix="${{
steps.release.outputs.basename }}/" -o "dist/${{ steps.release.outputs.basename
}}.zip" "${{ steps.release.outputs.tag }}"
-
- - name: Create draft GitHub release
- uses: softprops/action-gh-release@v2
- with:
- tag_name: ${{ steps.release.outputs.tag }}
- name: Casbin ${{ steps.release.outputs.tag }}
- body_path: RELEASE_NOTES.md
- draft: true
- files: |
- dist/${{ steps.release.outputs.basename }}.tar.gz
- dist/${{ steps.release.outputs.basename }}.zip
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]