feat: release categories for changelog #71
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Version and Changelog | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
update_version_changelog: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build | |
run: cargo build --verbose | |
- name: Run Tests | |
run: cargo test --verbose | |
- name: Calculate Version | |
uses: addnab/docker-run-action@v3 | |
with: | |
image: ghcr.io/coenraadhuman/gib:latest | |
shell: /bin/bash | |
options: -v ${{ github.workspace }}:/app | |
run : | | |
echo "=====================" | |
echo "Files mounted on /app" | |
echo "=====================" | |
ls -la /app | |
echo "=========================" | |
echo "Calculate Project Version" | |
echo "=========================" | |
calculated_version=$(gib version -p /app) | |
echo "Calculated version: $calculated_version" | |
echo "=============================" | |
echo "Replace version in Cargo.toml" | |
echo "=============================" | |
# Todo: validation before replace. | |
#semantic_version_regex='(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?' | |
#if [[ "$calculated_version" =~ $semantic_version_regex ]]; then | |
sed -i '0, /version/s/version.*/version = "'$(echo $calculated_version)'"/' /app/Cargo.toml | |
echo "Updated Cargo.toml with new version value." | |
#else | |
# echo "Invalid version, can't update version in Cargo.toml" | |
# exit 1 | |
#fi | |
echo "==================" | |
echo "Generate Changelog" | |
echo "==================" | |
gib changelog -p /app > CHANGELOG.md | |
echo "Updated CHANGELOG.md" | |
- name: Commit Changes | |
run: | | |
git config --global user.name "$(git log -1 --pretty=%an)" | |
git config --global user.email "$(git log -1 --pretty=%ae)" | |
git add ./Cargo.toml | |
git add ./CHANGELOG.md | |
git commit --amend --no-edit | |
git push -f |