Skip to content

Create Tag and Release changelog #18

Create Tag and Release changelog

Create Tag and Release changelog #18

name: Create Tag and Release changelog
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the new release'
required: true
permissions:
contents: write
packages: write
pull-requests: write
jobs:
fetch-tag:
runs-on: ubuntu-latest
outputs:
old_tag: ${{ steps.get_tag.outputs.old_tag_name }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get latest tag
id: get_tag
run: echo "old_tag_name=$(git ls-remote --tags origin | awk -F"/" '{print $3}' | grep -v '{}' | sort -V | tail -n1)" >> $GITHUB_OUTPUT
changelog:
name: Build Changelog
needs: [fetch-tag]
runs-on: ubuntu-latest
outputs:
changelog: ${{ steps.build_changelog.outputs.changelog }}
env:
old_tag: ${{ needs.fetch-tag.outputs.old_tag }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: changelog print old tag
run: echo "old_tag is $old_tag"
- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v4
with:
fromTag: ${{ needs.fetch-tag.outputs.old_tag }}
toTag: ${{ github.event.inputs.tag_name }}
token: ${{ github.TOKEN }}
- name: print_output
run: echo "${{ toJson(steps.build_changelog.outputs) }}"
#echo "Changelog output:" ${{ steps.build_changelog.outputs }}
release:
name: Release
needs: [changelog,fetch-tag]
runs-on: ubuntu-latest
env:
changelog: ${{ needs.changelog.outputs.changelog }}
old_tag: ${{ needs.fetch-tag.outputs.old_tag }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Generate Release Notes
run: echo ${{ env.changelog }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
token: ${{ github.TOKEN }}
tag_name: ${{ github.event.inputs.tag_name }}
prerelease: false
draft: false
files: bin/*
generate_release_notes: true
name: ${{ github.event.inputs.tag_name }}
body: |
## What's Changed
### abcd/ABCD
https://github.com/Kaustubh-pande/scaffolding-microservice/releases/tags/${{ env.old_tag }}
### xyz/XYZ
${{ needs.changelog.outputs.changelog }}