Skip to content

Release

Release #8

Workflow file for this run

name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
release:
runs-on: windows-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history including tags
- name: Get previous tag
id: get_previous_tag
shell: pwsh
run: |
$tags = git tag --sort=-creatordate
$tagsArray = $tags -split "`n"
$prevTag = if ($tagsArray.Length -ge 2) { $tagsArray[1].Trim() } else { "" }
Write-Host "Previous tag: $prevTag"
echo "PREV_TAG=$prevTag" >> $env:GITHUB_ENV
- name: Create release notes
id: create_release_notes
shell: pwsh
run: |
echo "## Release Notes" > release_notes.md
echo "" >> release_notes.md
echo "### Changes in this release:" >> release_notes.md
echo "" >> release_notes.md
$PREV_TAG = $env:PREV_TAG
Write-Host "Previous tag: $PREV_TAG"
if ([string]::IsNullOrEmpty($PREV_TAG)) {
Write-Host "No previous tag found. Using fallback."
git log --pretty=format:%s "${GITHUB_REF}~2..${GITHUB_REF}" >> release_notes.md
} else {
git log --pretty=format:%s "$PREV_TAG..${GITHUB_REF}" >> release_notes.md
}
echo "" >> release_notes.md
- name: Extract tag name
id: extract_tag_name
shell: pwsh
run: |
$tagName = $env:GITHUB_REF -replace 'refs/tags/', ''
Write-Host "Tag name: $tagName"
echo "TAG_NAME=$tagName" >> $env:GITHUB_ENV
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}
release_name: Release ${{ env.TAG_NAME }}
body_path: ./release_notes.md
draft: false
- name: Upload PowerShell script
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mytotp.rc.ps1
asset_name: mytotp.rc.ps1
asset_content_type: text/plain
- name: Upload Bash script
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mytotp.rc
asset_name: mytotp.rc
asset_content_type: text/plain
- name: Upload README.md
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mytotp.rc.README.md
asset_name: README.md
asset_content_type: text/markdown