mirror of
				https://github.com/XRPLF/clio.git
				synced 2025-11-04 11:55:51 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			127 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			127 lines
		
	
	
		
			3.9 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
 | 
						|
 | 
						|
jobs:
 | 
						|
  release:
 | 
						|
    runs-on: heavy
 | 
						|
    container:
 | 
						|
      image: ghcr.io/xrplf/clio-ci:b2be4b51d1d81548ca48e2f2b8f67356b880c96d
 | 
						|
    env:
 | 
						|
      GH_REPO: ${{ github.repository }}
 | 
						|
      GH_TOKEN: ${{ github.token }}
 | 
						|
 | 
						|
    permissions:
 | 
						|
      contents: write
 | 
						|
 | 
						|
    steps:
 | 
						|
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
 | 
						|
        with:
 | 
						|
          fetch-depth: 0
 | 
						|
 | 
						|
      - name: Prepare runner
 | 
						|
        uses: XRPLF/actions/.github/actions/prepare-runner@7951b682e5a2973b28b0719a72f01fc4b0d0c34f
 | 
						|
        with:
 | 
						|
          disable_ccache: true
 | 
						|
 | 
						|
      - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
 | 
						|
        with:
 | 
						|
          path: release_artifacts
 | 
						|
          pattern: clio_server_*
 | 
						|
 | 
						|
      - name: Create release notes
 | 
						|
        shell: bash
 | 
						|
        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
 | 
						|
        shell: bash
 | 
						|
        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"
 | 
						|
          cat CHANGELOG.md >> "${RUNNER_TEMP}/release_notes.md"
 | 
						|
 | 
						|
      - name: Prepare release artifacts
 | 
						|
        shell: bash
 | 
						|
        run: .github/scripts/prepare-release-artifacts.sh release_artifacts
 | 
						|
 | 
						|
      - name: Upload release notes
 | 
						|
        uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
 | 
						|
        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 != '' }}
 | 
						|
        shell: bash
 | 
						|
        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' }}
 | 
						|
        shell: bash
 | 
						|
        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_server*
 |