Skip to content

feat(ci): fetch tags info when run git cliff in workflow #12

feat(ci): fetch tags info when run git cliff in workflow

feat(ci): fetch tags info when run git cliff in workflow #12

Workflow file for this run

name: build
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
permissions:
contents: write
jobs:
build-rust:
strategy:
matrix:
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Install Rust
run: rustup toolchain install stable --component llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: install nextest
uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Check code format
run: cargo fmt -- --check
- name: Check the package for errors
run: cargo check --all
- name: Lint rust sources
run: cargo clippy --all-targets --all-features --tests --benches -- -D warnings
- name: Execute rust tests
run: cargo nextest run --all-features
- name: Get tags info
id: get_tag_message
run: git fetch origin +refs/tags/*:refs/tags/*
if: startsWith(github.ref, 'refs/tags/')
- name: Generate a changelog
uses: orhun/git-cliff-action@v3
id: git-cliff
if: startsWith(github.ref, 'refs/tags/')
with:
config: cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: NEW_CHANGELOG.md
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
body: ${{ steps.git-cliff.outputs.content }}
- name: Prepend new changelog to existing CHANGELOG.md
run: |
cat NEW_CHANGELOG.md
git fetch origin main:main
git checkout main
if [ -f "CHANGELOG.md" ]; then
head -n 1 CHANGELOG.md > TEMP_CHANGELOG.md
echo "" >> TEMP_CHANGELOG.md
cat NEW_CHANGELOG.md >> TEMP_CHANGELOG.md
tail -n +2 CHANGELOG.md >> TEMP_CHANGELOG.md
mv TEMP_CHANGELOG.md CHANGELOG.md
else
mv NEW_CHANGELOG.md CHANGELOG.md
fi
rm -f NEW_CHANGELOG.md
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
git add CHANGELOG.md
git commit -m "[skip] Update CHANGELOG.md with new changes"
git push origin main --force
if: startsWith(github.ref, 'refs/tags/') && steps.git-cliff.outputs.content != ''