test release workflow #49
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: Release Mikupad | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: Determine Tag and Build Names | |
id: Tag_Name | |
run: | | |
BUILD_NUMBER="$(git rev-list --count HEAD)" | |
echo "number=${BUILD_NUMBER}" >> $GITHUB_OUTPUT | |
SHORT_HASH="$(git rev-parse --short=7 HEAD)" | |
echo "buildName=Mikupad #${BUILD_NUMBER} [${SHORT_HASH}]" >> $GITHUB_OUTPUT | |
echo ${BUILD_NUMBER} | |
echo ${SHORT_HASH} | |
- name: Get Last Release Tag | |
id: last_release | |
run: | | |
TAG=$(git tag --list 'release*' --sort=-v:refname | head -n 1) | |
if [ -z "$TAG" ]; then | |
echo "No release tag found" | |
echo "tag=$(echo 'none')" >> $GITHUB_OUTPUT | |
else | |
TAG_NUMBER=$(echo $TAG | sed 's/release//') | |
echo "Found release tag: $TAG" | |
echo "tag=$TAG_NUMBER" >> $GITHUB_OUTPUT | |
fi | |
- name: Generate Changelog | |
id: changelog | |
run: | | |
if [ "${{ steps.last_release.outputs.tag }}" = "none" ]; then | |
echo "mikudayo~" > CHANGELOG.txt | |
else | |
NEW_COMMIT="${{ steps.last_release.outputs.tag }}" | |
NUM_COMMITS="${{ steps.Tag_Name.outputs.number }}" | |
echo "$(($NUM_COMMITS - $NEW_COMMIT))" | |
N_COMMITS="$(($NUM_COMMITS - $NEW_COMMIT))" | |
echo "Generating changelog starting from commit $NEW_COMMIT" | |
echo "$(date +'%Y-%m-%d %T')" >> CHANGELOG.txt | |
echo "\`\`\`" >> CHANGELOG.txt | |
echo "$(git log --graph -n $N_COMMITS --oneline)" >> CHANGELOG.txt | |
echo "\`\`\`" >> CHANGELOG.txt | |
echo "$(git log --graph -n $N_COMMITS --oneline)" | |
fi | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: release${{ steps.Tag_Name.outputs.number }} | |
name: ${{ steps.Tag_Name.outputs.buildName }} | |
body_path: CHANGELOG.txt | |
files: mikupad_compiled.html | |
token: ${{ secrets.GITHUB_TOKEN }} | |