-
Notifications
You must be signed in to change notification settings - Fork 47
168 lines (148 loc) · 5.25 KB
/
release.yaml
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
name: Release
run-name: Release ${{ inputs.version }}
on:
workflow_dispatch:
inputs:
version:
description: "The version to release (eg: 'v1.0.0')"
required: true
type: string
draft:
description: "Create a draft release?"
required: false
type: boolean
default: true
prerelease:
description: "Create a prerelease?"
required: false
type: boolean
default: true
release-nexus-mods:
description: "Release on Nexus Mods?"
required: false
type: boolean
default: false
notify-discord:
description: "Notify on Discord?"
required: false
type: boolean
default: false
notify-slack:
description: "Notify on Slack?"
required: false
type: boolean
default: false
env:
ProjectFile: "src/NexusMods.App/NexusMods.App.csproj"
jobs:
transformInputs:
runs-on: ubuntu-latest
outputs:
TagVersion: ${{ steps.setOutputs.outputs.tagVersion }}
RawVersion: ${{ steps.setOutputs.outputs.rawVersion }}
ProjectFile: ${{ steps.setOutputs.outputs.projectFile }}
steps:
- name: Set Outputs
id: setOutputs
shell: pwsh
env:
InputVersion: ${{ inputs.version }}
run: |
$tagVersion = $env:InputVersion.StartsWith('v') ? $env:InputVersion : "v" + $env:InputVersion
$rawVersion = $env:InputVersion.StartsWith('v') ? $env:InputVersion.Substring(1) : $env:InputVersion
$validation = [System.Version]::Parse($rawVersion)
echo "tagVersion=$tagVersion" >> $env:GITHUB_OUTPUT
echo "rawVersion=$rawVersion" >> $env:GITHUB_OUTPUT
echo "projectFile=${{ env.ProjectFile }}" >> $env:GITHUB_OUTPUT
build-linux:
needs: [ transformInputs ]
uses: ./.github/workflows/build-linux-pupnet.yaml
with:
AppVersion: ${{ needs.transformInputs.outputs.RawVersion }}
# this is a bit of a hack, you can't use environment variables here
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
ProjectFile: ${{ needs.transformInputs.outputs.ProjectFile }}
RetentionDays: 1
build-windows:
needs: [ transformInputs ]
uses: ./.github/workflows/build-windows-pupnet.yaml
with:
AppVersion: ${{ needs.transformInputs.outputs.RawVersion }}
# this is a bit of a hack, you can't use environment variables here
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
ProjectFile: ${{ needs.transformInputs.outputs.ProjectFile }}
RetentionDays: 1
SignExecutable: true
secrets:
ES_USERNAME: ${{ secrets.ES_USERNAME }}
ES_PASSWORD: ${{ secrets.ES_PASSWORD }}
ES_CREDENTIAL_ID: ${{ secrets.ES_CREDENTIAL_ID }}
ES_TOTP_SECRET: ${{ secrets.ES_TOTP_SECRET }}
release-github:
runs-on: ubuntu-latest
needs: [ transformInputs, build-linux, build-windows ]
outputs:
GitHubReleaseUrl: ${{ steps.create-gh-release.outputs.url }}
permissions:
contents: write
discussions: write
steps:
- name: Get Linux Archive
uses: actions/download-artifact@v3
with:
name: ${{ needs.build-linux.outputs.ArtifactNameLinuxArchive }}
path: bin/LinuxArchive
- name: Get Linux AppImage
uses: actions/download-artifact@v3
with:
name: ${{ needs.build-linux.outputs.ArtifactNameLinuxAppImage }}
path: bin/LinuxAppImage
- name: Get Windows Archive
uses: actions/download-artifact@v3
with:
name: ${{ needs.build-windows.outputs.ArtifactNameWindowsArchive }}
path: bin/WindowsArchive
- name: Get Windows Inno Setup
uses: actions/download-artifact@v3
with:
name: ${{ needs.build-windows.outputs.ArtifactNameWindowsInnoSetup }}
path: bin/WindowsInnoSetup
- name: List Artifacts
shell: bash
run: tree bin
- name: Create Release
id: create-gh-release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.transformInputs.outputs.RawVersion }}
tag_name: ${{ needs.transformInputs.outputs.TagVersion }}
draft: ${{ inputs.draft }}
prerelease: ${{ inputs.prerelease }}
files: bin/**/*
fail_on_unmatched_files: true
release-nexus-mods:
runs-on: ubuntu-latest
needs: [ transformInputs, build-linux, build-windows ]
steps:
- name: Empty
if: inputs.release-nexus-mods == true
run: exit 0
notify-discord:
runs-on: ubuntu-latest
needs: [ release-github, release-nexus-mods ]
steps:
- name: Send Discord notification
if: inputs.notify-discord == true
uses: appleboy/[email protected]
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
message: "New release is available at ${{ needs.release-github.outputs.GitHubReleaseUrl }}"
username: "Release Bot"
notify-slack:
runs-on: ubuntu-latest
needs: [ release-github, release-nexus-mods ]
steps:
- name: Empty
if: inputs.notify-slack == true
run: exit 0