|
|
|
@@ -32,14 +32,11 @@ jobs:
|
|
|
|
|
fi
|
|
|
|
|
echo "Release token found"
|
|
|
|
|
|
|
|
|
|
changelog:
|
|
|
|
|
name: Generate Changelog
|
|
|
|
|
changelog-and-pr:
|
|
|
|
|
name: Generate Changelog and Handle PR
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
needs: preconditions
|
|
|
|
|
if: github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch
|
|
|
|
|
outputs:
|
|
|
|
|
version: ${{ steps.version.outputs.version }}
|
|
|
|
|
has_changes: ${{ steps.check.outputs.has_changes }}
|
|
|
|
|
steps:
|
|
|
|
|
- name: Checkout
|
|
|
|
|
uses: actions/checkout@v6
|
|
|
|
@@ -75,27 +72,8 @@ jobs:
|
|
|
|
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
- name: Upload artifacts
|
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
|
with:
|
|
|
|
|
name: changelog-artifacts
|
|
|
|
|
path: |
|
|
|
|
|
CHANGES.md
|
|
|
|
|
CHANGELOG.md
|
|
|
|
|
VERSION
|
|
|
|
|
|
|
|
|
|
handle-pr:
|
|
|
|
|
name: Handle Release PR
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
needs: changelog
|
|
|
|
|
if: needs.changelog.outputs.has_changes == 'true'
|
|
|
|
|
steps:
|
|
|
|
|
- name: Download artifacts
|
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
|
with:
|
|
|
|
|
name: changelog-artifacts
|
|
|
|
|
|
|
|
|
|
- name: Create or update release PR
|
|
|
|
|
if: steps.check.outputs.has_changes == 'true'
|
|
|
|
|
env:
|
|
|
|
|
REPOSITORY: ${{ github.repository }}
|
|
|
|
|
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
|
|
@@ -244,15 +222,14 @@ jobs:
|
|
|
|
|
"${API_URL}/pulls"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
prepare-release:
|
|
|
|
|
name: Prepare Release
|
|
|
|
|
create-release:
|
|
|
|
|
name: Create Release
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
needs: preconditions
|
|
|
|
|
if: |
|
|
|
|
|
(github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch) ||
|
|
|
|
|
github.ref_type == 'tag'
|
|
|
|
|
outputs:
|
|
|
|
|
version: ${{ steps.version.outputs.version }}
|
|
|
|
|
github.ref_type == 'branch' &&
|
|
|
|
|
github.ref_name == github.event.repository.default_branch &&
|
|
|
|
|
inputs.tag_only != true
|
|
|
|
|
steps:
|
|
|
|
|
- name: Checkout
|
|
|
|
|
uses: actions/checkout@v6
|
|
|
|
@@ -266,51 +243,19 @@ jobs:
|
|
|
|
|
git-cliff --version
|
|
|
|
|
|
|
|
|
|
- name: Generate changelog
|
|
|
|
|
run: |
|
|
|
|
|
if [ "${{ github.ref_type }}" = "tag" ]; then
|
|
|
|
|
git-cliff --bump --latest --strip header > CHANGES.md
|
|
|
|
|
else
|
|
|
|
|
git-cliff --bump --unreleased --strip header > CHANGES.md
|
|
|
|
|
fi
|
|
|
|
|
run: git-cliff --bump --unreleased --strip header > CHANGES.md
|
|
|
|
|
|
|
|
|
|
- name: Get version
|
|
|
|
|
id: version
|
|
|
|
|
run: |
|
|
|
|
|
VERSION=$(git-cliff --bumped-version 2>/dev/null || echo "")
|
|
|
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
|
echo "${VERSION}" > VERSION
|
|
|
|
|
|
|
|
|
|
- name: Upload artifacts
|
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
|
with:
|
|
|
|
|
name: release-artifacts
|
|
|
|
|
path: |
|
|
|
|
|
CHANGES.md
|
|
|
|
|
VERSION
|
|
|
|
|
|
|
|
|
|
create-release:
|
|
|
|
|
name: Create Release
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
needs: prepare-release
|
|
|
|
|
if: |
|
|
|
|
|
github.ref_type == 'branch' &&
|
|
|
|
|
github.ref_name == github.event.repository.default_branch &&
|
|
|
|
|
inputs.tag_only != true
|
|
|
|
|
steps:
|
|
|
|
|
- name: Checkout
|
|
|
|
|
uses: actions/checkout@v6
|
|
|
|
|
with:
|
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
|
|
- name: Download artifacts
|
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
|
with:
|
|
|
|
|
name: release-artifacts
|
|
|
|
|
|
|
|
|
|
- name: Create release
|
|
|
|
|
env:
|
|
|
|
|
REPOSITORY: ${{ github.repository }}
|
|
|
|
|
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
|
|
|
VERSION: ${{ steps.version.outputs.version }}
|
|
|
|
|
run: |
|
|
|
|
|
TOKEN=$(cat "${RELEASE_TOKEN_FILE}")
|
|
|
|
|
if [ ! -r .version ]; then
|
|
|
|
@@ -318,11 +263,11 @@ jobs:
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
VERSION=$(cat .version 2>/dev/null | jq -r '.version')
|
|
|
|
|
CURRENT_VERSION=$(cat .version 2>/dev/null | jq -r '.version')
|
|
|
|
|
LATEST=$(git describe --abbrev=0 --tags 2>/dev/null || echo '')
|
|
|
|
|
|
|
|
|
|
if [ -n "${LATEST}" ] && [ "${VERSION}" = "${LATEST}" ]; then
|
|
|
|
|
echo "Version ${VERSION} already exists"
|
|
|
|
|
if [ -n "${LATEST}" ] && [ "${CURRENT_VERSION}" = "${LATEST}" ]; then
|
|
|
|
|
echo "Version ${CURRENT_VERSION} already exists"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@@ -330,17 +275,16 @@ jobs:
|
|
|
|
|
REPO=$(echo "${REPOSITORY}" | cut -d'/' -f2)
|
|
|
|
|
API_URL="${GITEA_URL}/api/v1/repos/${OWNER}/${REPO}"
|
|
|
|
|
|
|
|
|
|
NAME=$(cat VERSION)
|
|
|
|
|
MESSAGE=$(cat CHANGES.md | jq -Rs .)
|
|
|
|
|
MESSAGE="${MESSAGE:1:-1}" # Remove surrounding quotes
|
|
|
|
|
|
|
|
|
|
echo "Creating release ${NAME}..."
|
|
|
|
|
echo "Creating release ${VERSION}..."
|
|
|
|
|
curl -sf -X POST \
|
|
|
|
|
-H "Authorization: token ${TOKEN}" \
|
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
|
--data "$(jq -n \
|
|
|
|
|
--arg tag_name "${NAME}" \
|
|
|
|
|
--arg name "${NAME}" \
|
|
|
|
|
--arg tag_name "${VERSION}" \
|
|
|
|
|
--arg name "${VERSION}" \
|
|
|
|
|
--arg body "${MESSAGE}" \
|
|
|
|
|
--arg target "${DEFAULT_BRANCH}" \
|
|
|
|
|
'{tag_name: $tag_name, name: $name, body: $body, target_commitish: $target}')" \
|
|
|
|
@@ -349,7 +293,7 @@ jobs:
|
|
|
|
|
create-tag:
|
|
|
|
|
name: Create Tag
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
needs: prepare-release
|
|
|
|
|
needs: preconditions
|
|
|
|
|
if: |
|
|
|
|
|
github.ref_type == 'branch' &&
|
|
|
|
|
github.ref_name == github.event.repository.default_branch &&
|
|
|
|
@@ -360,15 +304,23 @@ jobs:
|
|
|
|
|
with:
|
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
|
|
- name: Download artifacts
|
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
|
with:
|
|
|
|
|
name: release-artifacts
|
|
|
|
|
- name: Install git-cliff
|
|
|
|
|
run: |
|
|
|
|
|
curl -sSfL "https://github.com/orhun/git-cliff/releases/download/v${GIT_CLIFF_VERSION}/git-cliff-${GIT_CLIFF_VERSION}-x86_64-unknown-linux-gnu.tar.gz" | tar xz
|
|
|
|
|
sudo mv "git-cliff-${GIT_CLIFF_VERSION}/git-cliff" /usr/local/bin/
|
|
|
|
|
git-cliff --version
|
|
|
|
|
|
|
|
|
|
- name: Get version
|
|
|
|
|
id: version
|
|
|
|
|
run: |
|
|
|
|
|
VERSION=$(git-cliff --bumped-version 2>/dev/null || echo "")
|
|
|
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
|
|
- name: Create tag
|
|
|
|
|
env:
|
|
|
|
|
REPOSITORY: ${{ github.repository }}
|
|
|
|
|
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
|
|
|
VERSION: ${{ steps.version.outputs.version }}
|
|
|
|
|
run: |
|
|
|
|
|
TOKEN=$(cat "${RELEASE_TOKEN_FILE}")
|
|
|
|
|
if [ ! -r .version ]; then
|
|
|
|
@@ -376,11 +328,11 @@ jobs:
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
VERSION=$(cat .version 2>/dev/null | jq -r '.version')
|
|
|
|
|
CURRENT_VERSION=$(cat .version 2>/dev/null | jq -r '.version')
|
|
|
|
|
LATEST=$(git describe --abbrev=0 --tags 2>/dev/null || echo '')
|
|
|
|
|
|
|
|
|
|
if [ -n "${LATEST}" ] && [ "${VERSION}" = "${LATEST}" ]; then
|
|
|
|
|
echo "Version ${VERSION} already exists"
|
|
|
|
|
if [ -n "${LATEST}" ] && [ "${CURRENT_VERSION}" = "${LATEST}" ]; then
|
|
|
|
|
echo "Version ${CURRENT_VERSION} already exists"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@@ -388,15 +340,13 @@ jobs:
|
|
|
|
|
REPO=$(echo "${REPOSITORY}" | cut -d'/' -f2)
|
|
|
|
|
API_URL="${GITEA_URL}/api/v1/repos/${OWNER}/${REPO}"
|
|
|
|
|
|
|
|
|
|
NAME=$(cat VERSION)
|
|
|
|
|
|
|
|
|
|
echo "Creating tag ${NAME}..."
|
|
|
|
|
echo "Creating tag ${VERSION}..."
|
|
|
|
|
curl -sf -X POST \
|
|
|
|
|
-H "Authorization: token ${TOKEN}" \
|
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
|
--data "$(jq -n \
|
|
|
|
|
--arg tag_name "${NAME}" \
|
|
|
|
|
--arg tag_name "${VERSION}" \
|
|
|
|
|
--arg target "${DEFAULT_BRANCH}" \
|
|
|
|
|
--arg message "${NAME}" \
|
|
|
|
|
--arg message "${VERSION}" \
|
|
|
|
|
'{tag_name: $tag_name, target: $target, message: $message}')" \
|
|
|
|
|
"${API_URL}/tags"
|
|
|
|
|