forked from ThingCrimson/mytotp
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (86 loc) · 2.96 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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