blob: 84f68a8f85933f7ad9a508e5699022b8c26ec917 [file]
# 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
#
# https://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: Release
on:
push:
tags: ['v*-rc*']
workflow_dispatch:
inputs:
tag:
description: 'Existing final tag vX.Y.Z, pointing at the approved candidate commit'
required: true
type: string
project_result:
description: 'Public project vote result URL (lists.apache.org/thread/...)'
required: true
type: string
incubator_result:
description: 'Public IPMC vote result URL (lists.apache.org/thread/...)'
required: true
type: string
permissions:
contents: write
concurrency:
group: release-${{ github.repository }}-${{ inputs.tag || github.ref_name }}
cancel-in-progress: false
jobs:
release:
if: github.repository == 'apache/casbin-cpp' && (github.event_name == 'push' || github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ inputs.tag || github.ref }}
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.12'
- name: Validate mode and committed version
id: meta
env:
TAG: ${{ inputs.tag || github.ref_name }}
EVENT: ${{ github.event_name }}
PROJECT_RESULT: ${{ inputs.project_result }}
INCUBATOR_RESULT: ${{ inputs.incubator_result }}
run: |
set -euo pipefail
python .github/scripts/release.py meta "$TAG" >> "$GITHUB_OUTPUT"
if [[ "$EVENT" == workflow_dispatch ]]; then
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
[[ "$PROJECT_RESULT" =~ ^https://lists\.apache\.org/thread/[a-z0-9]+$ ]]
[[ "$INCUBATOR_RESULT" =~ ^https://lists\.apache\.org/thread/[a-z0-9]+$ ]]
else
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc[1-9][0-9]*$ ]]
fi
- name: Export unsigned source candidate
if: steps.meta.outputs.is_rc == 'true'
env:
TAG: ${{ github.ref_name }}
run: python .github/scripts/release.py archive "$TAG"
- name: Verify approved ASF originals against the final tag
if: steps.meta.outputs.is_rc == 'false'
env:
TAG: ${{ inputs.tag }}
run: python .github/scripts/release.py verify "$TAG"
- name: Refuse replacement of an existing GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag || github.ref_name }}
run: |
set -euo pipefail
if gh release view "$TAG" >/dev/null 2>&1; then
echo '::error::Release exists; assets will not be overwritten. Inspect partial publication before retrying.'
exit 1
fi
- name: Write release notes
env:
IS_RC: ${{ steps.meta.outputs.is_rc }}
VERSION: ${{ steps.meta.outputs.version }}
PROJECT_RESULT: ${{ inputs.project_result }}
INCUBATOR_RESULT: ${{ inputs.incubator_result }}
run: |
printf 'Apache Casbin (Incubating) — C++ %s\n\n' "$VERSION" > release-notes.md
cat DISCLAIMER >> release-notes.md
if [[ "$IS_RC" == true ]]; then
printf '\n\nUnsigned source candidate for review; the RM must sign and stage it before voting. This is not an approved release.\n' >> release-notes.md
else
printf '\n\nProject result: %s\nIPMC result: %s\nSource assets are the approved ASF originals.\n' "$PROJECT_RESULT" "$INCUBATOR_RESULT" >> release-notes.md
printf '\nSource: https://downloads.apache.org/incubator/casbin/cpp-%s-incubating/\nKEYS: https://downloads.apache.org/incubator/casbin/KEYS\nVerification: https://www.apache.org/info/verification.html\n' "$VERSION" >> release-notes.md
fi
- name: Create GitHub release without replacing assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag || github.ref_name }}
IS_RC: ${{ steps.meta.outputs.is_rc }}
run: |
set -euo pipefail
kind=(--latest)
if [[ "$IS_RC" == true ]]; then kind=(--prerelease --latest=false); fi
gh release create "$TAG" --title "$TAG (Apache Casbin Incubating)" --notes-file release-notes.md "${kind[@]}" dist-release/*.tar.gz dist-release/*.sha512 $(find dist-release -maxdepth 1 -name '*.asc' -print)