mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
130 lines
4.0 KiB
YAML
130 lines
4.0 KiB
YAML
name: Make release
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
delete_pattern:
|
|
description: "Pattern to delete previous releases"
|
|
required: true
|
|
type: string
|
|
|
|
prerelease:
|
|
description: "Create a prerelease"
|
|
required: true
|
|
type: boolean
|
|
|
|
title:
|
|
description: "Release title"
|
|
required: true
|
|
type: string
|
|
|
|
version:
|
|
description: "Release version"
|
|
required: true
|
|
type: string
|
|
|
|
header:
|
|
description: "Release notes header"
|
|
required: true
|
|
type: string
|
|
|
|
generate_changelog:
|
|
description: "Generate changelog"
|
|
required: true
|
|
type: boolean
|
|
|
|
draft:
|
|
description: "Create a draft release"
|
|
required: true
|
|
type: boolean
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: heavy
|
|
container:
|
|
image: ghcr.io/xrplf/clio-ci:14342e087ceb8b593027198bf9ef06a43833c696
|
|
env:
|
|
GH_REPO: ${{ github.repository }}
|
|
GH_TOKEN: ${{ github.token }}
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Prepare runner
|
|
uses: XRPLF/actions/prepare-runner@2cbf481018d930656e9276fcc20dc0e3a0be5b6d
|
|
with:
|
|
enable_ccache: false
|
|
|
|
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
path: release_artifacts
|
|
pattern: clio_server_*
|
|
|
|
- name: Prepare release artifacts
|
|
run: .github/scripts/prepare-release-artifacts.sh release_artifacts
|
|
|
|
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
path: release_artifacts
|
|
pattern: clio_deb_package_*
|
|
|
|
- name: Create release notes
|
|
env:
|
|
RELEASE_HEADER: ${{ inputs.header }}
|
|
run: |
|
|
echo "# Release notes" > "${RUNNER_TEMP}/release_notes.md"
|
|
echo "" >> "${RUNNER_TEMP}/release_notes.md"
|
|
printf '%s\n' "${RELEASE_HEADER}" >> "${RUNNER_TEMP}/release_notes.md"
|
|
|
|
- name: Generate changelog
|
|
if: ${{ inputs.generate_changelog }}
|
|
run: |
|
|
LAST_TAG="$(gh release view --json tagName -q .tagName --repo XRPLF/clio)"
|
|
LAST_TAG_COMMIT="$(git rev-parse $LAST_TAG)"
|
|
BASE_COMMIT="$(git merge-base HEAD $LAST_TAG_COMMIT)"
|
|
git-cliff "${BASE_COMMIT}..HEAD" --ignore-tags "nightly|-b|-rc" >> "${RUNNER_TEMP}/release_notes.md"
|
|
|
|
- name: Upload release notes
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: release_notes_${{ inputs.version }}
|
|
path: "${RUNNER_TEMP}/release_notes.md"
|
|
|
|
- name: Remove previous release with a pattern
|
|
if: ${{ github.event_name != 'pull_request' && inputs.delete_pattern != '' }}
|
|
env:
|
|
DELETE_PATTERN: ${{ inputs.delete_pattern }}
|
|
run: |
|
|
RELEASES_TO_DELETE=$(gh release list --limit 50 --repo "${GH_REPO}" | grep -E "${DELETE_PATTERN}" | awk -F'\t' '{print $3}' || true)
|
|
if [ -n "$RELEASES_TO_DELETE" ]; then
|
|
for RELEASE in $RELEASES_TO_DELETE; do
|
|
echo "Deleting release: $RELEASE"
|
|
gh release delete "$RELEASE" --repo "${GH_REPO}" --yes --cleanup-tag
|
|
done
|
|
fi
|
|
|
|
- name: Publish release
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
env:
|
|
RELEASE_VERSION: ${{ inputs.version }}
|
|
PRERELEASE_OPTION: ${{ inputs.prerelease && '--prerelease' || '' }}
|
|
RELEASE_TITLE: ${{ inputs.title }}
|
|
DRAFT_OPTION: ${{ inputs.draft && '--draft' || '' }}
|
|
run: |
|
|
gh release create "${RELEASE_VERSION}" \
|
|
${PRERELEASE_OPTION} \
|
|
--title "${RELEASE_TITLE}" \
|
|
--target "${GITHUB_SHA}" \
|
|
${DRAFT_OPTION} \
|
|
--notes-file "${RUNNER_TEMP}/release_notes.md" \
|
|
./release_artifacts/clio_*
|