Skip to content

ci: Output changelog to file and include changelog in release #2

ci: Output changelog to file and include changelog in release

ci: Output changelog to file and include changelog in release #2

Workflow file for this run

name: Continuous Deployment
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
generate-changelog:
name: Generate changelog
runs-on: ubuntu-22.04
outputs:
changelog_body: ${{ steps.read_changelog.outputs.CHANGELOG_BODY }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@main
id: git-cliff
with:
config: cliff.toml
args: -vv --latest --no-exec --github-repo ${{ github.repository }} -o CHANGELOG.md
- name: Commit
run: |
git checkout ${{ github.ref_name }}
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
set +e
git add CHANGELOG.md
git commit -m "Update changelog"
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git ${{ github.ref_name }}
- name: Read CHANGELOG.md
id: read_changelog
shell: bash
run: |
r=$(cat CHANGELOG.md) # <--- Read release.md (Provide correct path as per your repo)
r="${r//'%'/'%25'}" # Multiline escape sequences for %
r="${r//$'\n'/'%0A'}" # Multiline escape sequences for '\n'
r="${r//$'\r'/'%0D'}" # Multiline escape sequences for '\r'
echo "CHANGELOG_BODY=$r" >> $GITHUB_OUTPUT # <--- Set environment variable
publish:
name: Build and publish shadowJar
needs: generate-changelog
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: ./gradlew shadowDistTar shadowDistZip
- name: Move to out dir
run: |
mkdir -p out
mv build/distributions/* out/
mv build/libs/* out/
- name: Upload Binaries to Release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
body: ${{ needs.generate-changelog.outputs.changelog_body }}
file: out/*
file_glob: true
overwrite: true