Skip to content

Update release.yml #122

Update release.yml

Update release.yml #122

Workflow file for this run

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Release
permissions: write-all
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 16
- name: Install dependencies
run: npm install -g conventional-changelog-cli
- name: Find last tag
id: last_tag
run: echo "::set-output name=tag::$(git describe --tags --abbrev=0 || echo 'v0.0.0')"
- name: Generate new version number
id: version
run: |
LAST_TAG=${{ steps.last_tag.outputs.tag }}
if [[ $LAST_TAG == v* ]]; then
VERSION=$(echo $LAST_TAG | sed 's/v//')
MAJOR=$(echo $VERSION | cut -d'.' -f1)
MINOR=$(echo $VERSION | cut -d'.' -f2)
PATCH=$(echo $VERSION | cut -d'.' -f3)
((PATCH++))
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
else
NEW_VERSION="1.0.0"
fi
echo "::set-output name=new_version::$NEW_VERSION"
- name: Generate changelog since last tag
run: |
conventional-changelog -p angular -i CHANGELOG.md -s -r ${{ steps.last_tag.outputs.tag }}..HEAD -o CHANGELOG_FRAGMENT.md
cat CHANGELOG_FRAGMENT.md >> CHANGELOG.md
- name: Push changes
run: |
git push origin main
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: v${{ steps.version.outputs.new_version }}
release_name: Release v${{ steps.version.outputs.new_version }}
body_path: CHANGELOG_FRAGMENT.md
draft: false
prerelease: false
# - name: Push tag to repository
# run: |
# git tag v${{ steps.version.outputs.new_version }}
# git push origin v${{ steps.version.outputs.new_version }}