Skip to content

ci(release): add line seperations to initial commit history in changelog #39

ci(release): add line seperations to initial commit history in changelog

ci(release): add line seperations to initial commit history in changelog #39

Workflow file for this run

name: release
on:
push:
tags: ["v[0-9].[0-9]+.[0-9]+"]
permissions:
contents: write
jobs:
build_foxe:
name: build_foxe
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install dependencies
run: npm install
- name: Package
run: npm run package
- name: Extract version
id: extract_version
run: |
version=$(node -p "require('./package.json').version")
echo "version=$version" >> $GITHUB_ENV
- name: Update changelog file
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
yarn commitizen init cz-conventional-changelog --save-dev --force --save-exact
HEADER=$(awk '/^---/{exit} {print}' CHANGELOG.md)
yarn conventional-changelog -p angular -o TEMP.md -r o
echo "$HEADER" > CHANGELOG.md
echo "" >> CHANGELOG.md
cat TEMP.md >> CHANGELOG.md
rm TEMP.md
- name: Fetch initial commit history
id: fetch_initial_commit_history
run: |
INITIAL_COMMIT_HISTORY=$(cat initial_commit_history.md)
echo "INITIAL_COMMIT_HISTORY<<EOF" >> $GITHUB_ENV
echo "$INITIAL_COMMIT_HISTORY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Insert initial commit history in changelog file
run: |
TARGET_TAG="0.0.1"
FILE="CHANGELOG.md"
INITIAL_COMMIT_HISTORY="$INITIAL_COMMIT_HISTORY"
if grep -q "## $TARGET_TAG \(([^)]*)\)" "$FILE"; then
sed -i "/## $TARGET_TAG \(([^)]*)\)/,/^## /{//!d}" "$FILE"
sed -i "/## $TARGET_TAG \(([^)]*)\)/a\\
$(echo "$INITIAL_COMMIT_HISTORY" | sed 's/[&/\]/\\&/g')" "$FILE"
echo "Initial commit history inserted under the ## $TARGET_TAG header in $FILE."
else
echo "Tag ## $TARGET_TAG not found in $FILE."
fi
- name: Commit changelog changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md
git commit -m "chore: update changelog for $GITHUB_REF"
- name: Create GitHub Release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ASAM OSI Converter ${{ env.version }}
draft: false
prerelease: false
- name: Upload Release Asset
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: lichtblick.asam-osi-converter-${{ env.version }}.foxe
asset_name: lichtblick.asam-osi-converter-${{ env.version }}.foxe
asset_content_type: application/octet-stream
- name: Upload Changelog
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./CHANGELOG.md
asset_name: CHANGELOG.md
asset_content_type: text/markdown