Skip to content

Release

Release #5

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
- name: Get previous tag
id: get_previous_tag
shell: pwsh
run: |
# Get all tags sorted by creation date in reverse order
$tags = git tag --sort=-creatordate
# Convert the tags to an array
$tagsArray = $tags -split "`n"
# Get the second latest tag
$prevTag = if ($tagsArray.Length -ge 2) { $tagsArray[1].Trim() } else { "" }
if (-not $prevTag) {
# will do stub
$prevTag = "v1.2.0"
}
# Write previous tag to environment file
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: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: ./release_notes.md
draft: false
prerelease: 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