-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (148 loc) · 6.73 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Automated .NET Release
on:
push:
paths-ignore:
- "**.yml"
branches:
- "main"
- "rel/**"
tags:
- "**"
workflow_dispatch:
permissions:
actions: write
checks: write
contents: write
jobs:
check_for_tag:
name: Check if tag has to be created
if: ${{ contains(github.event.head_commit.message, '[release]') || contains(github.event.head_commit.message, '[pre-release]') }}
uses: ./.github/workflows/tag-creation.yml
extract_meta:
name: Extract metadata for use
if: ${{ contains(github.event.head_commit.message, '[release]') || contains(github.event.head_commit.message, '[pre-release]') }}
runs-on: ubuntu-24.04
outputs:
loc_cs: ${{ steps.loc_cs.outputs.total_lines }}
changelog: ${{ steps.changelog.outputs.changelog }}
datetime: ${{ steps.dateTime.outputs.time }}
clean_version: ${{ steps.get-version.outputs.clean_version }}
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- name: Calculate Lines of Source Code
id: loc_cs
uses: PavanMudigonda/lines-of-code-reporter@6c5507f592136d1c05cb1e8c30889dc4eb5561f5
with:
include_lang: "C#,MSBuild script"
- name: Get correct changelog
id: changelog
run: |
if ${{ contains(github.event.head_commit.message, '[pre-release]') }}; then
echo "changelog=CHANGELOG.previews.md" >> "$GITHUB_OUTPUT"
else
echo "changelog=CHANGELOG.md" >> "$GITHUB_OUTPUT"
fi
- name: Get Date and Time
id: dateTime
uses: Kaven-Universe/github-action-current-date-time@f2c12d90cff9c3e7b1f50430886e632fe31fcee1
with:
format: "YYYY-MM-DDTHH:mm:ss"
- name: Get version from Directory.Build.props
id: get-version
run: |
VERSION=$(grep -oP '(?<=<Version>).*?(?=</Version>)' Directory.Build.props)
echo "version=v$VERSION" >> "$GITHUB_OUTPUT"
echo "clean_version=$VERSION" >> "$GITHUB_OUTPUT"
build-docker:
name: Build docker .zip file
needs: extract_meta
if: ${{ contains(github.event.head_commit.message, '[release]') || contains(github.event.head_commit.message, '[pre-release]') }}
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- name: Getting all files together
run: |
mkdir docker-zip
mv ./${{ needs.extract_meta.outputs.changelog }} ./docker-zip/CHANGELOG.md
mv ./docker-compose.yml ./docker-zip/docker-compose.yml
mv ./LICENSE ./docker-zip/LICENSE
mv ./README.md ./docker-zip/README.md
mv ./SECURITY.md ./docker-zip/SECURITY.md
mkdir -p ./docker-zip/AzzyBot/Logs
mkdir -p ./docker-zip/AzzyBot/Modules/AzuraCast/Files
mkdir -p ./docker-zip/AzzyBot/Modules/MusicStreaming/Files
mv ./src/AzzyBot.Bot/Modules/MusicStreaming/Files/application.yml ./docker-zip/AzzyBot/Modules/MusicStreaming/Files/application.yml
#wget -qO ./docker-zip/AzzyBot/Modules/MusicStreaming/Files/plugins/java-lyrics-plugin-1.6.4.jar https://maven.lavalink.dev/releases/me/duncte123/java-lyrics-plugin/1.6.4/java-lyrics-plugin-1.6.4.jar
mkdir -p ./docker-zip/AzzyBot/Settings
mv ./src/AzzyBot.Bot/Settings/AzzyBotSettings-Docker.json ./docker-zip/AzzyBot/Settings/AzzyBotSettings-Docker.json
- name: Archive docker-zip artifact
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b
with:
name: ${{ needs.extract_meta.outputs.clean_version }}-docker
path: ./docker-zip
create_release:
name: Create GitHub Release
needs: [extract_meta, build-docker]
runs-on: ubuntu-24.04
outputs:
release_version: ${{ steps.set_output.outputs.release_version }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Extract Latest Changelog Entry
id: extract_changelog
run: |
# Extract the latest changelog entry from the changelog file
latest_entry=$(awk 'BEGIN {found=0} /^## / {if (found) exit; found=1} {if (found) print}' ${{ needs.extract_meta.outputs.changelog }})
echo "$latest_entry" > latest_changelog.md
# Extract title for release
release_title=$(echo "$latest_entry" | awk 'NR==2')
# Ensure safe output handling for multiline strings
echo "latest_entry<<EOF" >> "$GITHUB_OUTPUT"
echo "$latest_entry" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
echo "release_title=$release_title" >> "$GITHUB_ENV"
- name: Create Release
id: create_release_action
uses: softprops/action-gh-release@7b4da11513bf3f43f9999e90eabced41ab8bb048
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.extract_meta.outputs.version }}
name: ${{ needs.extract_meta.outputs.clean_version }}
body_path: latest_changelog.md
prerelease: ${{ contains(github.event.head_commit.message, '[pre-release]') }}
- name: Set Release Version Output
id: set_output
run: |
echo "release_version=${{ needs.extract_meta.outputs.version }}" >> "$GITHUB_OUTPUT"
upload_assets:
name: Upload GitHub Release Assets
needs: [build-docker, create_release]
runs-on: ubuntu-24.04
steps:
- name: Install GitHub CLI
run: sudo apt-get update && sudo apt-get install -y gh
- name: Download and Upload All Artifacts
run: |
# Fetch a list of all artifact details for the current workflow run
ARTIFACTS_JSON=$(gh api /repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts)
# Ensure the command above is successful and returns valid JSON before proceeding
# Iterate over each artifact to download and upload it
echo "$ARTIFACTS_JSON" | jq -c '.artifacts[]' | while read -r artifact; do
ARTIFACT_NAME=$(echo "$artifact" | jq -r '.name')
ARTIFACT_DOWNLOAD_URL=$(echo "$artifact" | jq -r '.archive_download_url')
# Download the artifact
curl -L -o "${ARTIFACT_NAME}.zip" -H "Authorization: token $GITHUB_TOKEN" "$ARTIFACT_DOWNLOAD_URL"
# Upload the artifact to the release
gh release upload ${{ needs.create_release.outputs.release_version }} "${ARTIFACT_NAME}.zip" --clobber --repo ${{ github.repository }}
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}