-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (120 loc) · 4.84 KB
/
AutomatedRelease.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
name: "Automated Release"
on:
push:
branches:
- main
jobs:
build:
name: "Build"
runs-on: "windows-latest"
env:
working-directory: .
project-name: SRTPluginProviderRE7
platform: x64
configuration: Release
outputs:
project-name: ${{env.project-name}}
solution: ${{steps.generated-variables-1.outputs.solution}}
project: ${{steps.generated-variables-1.outputs.project}}
build-directory: ${{steps.generated-variables-1.outputs.build-directory}}
zip-filename: ${{steps.generated-variables-2.outputs.zip-filename}}
version: ${{steps.get_version.outputs.RELEASE_VERSION}}
steps:
# Checkout latest code
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
# Create repo user folder for the dependencies
- name: Create repo user folder
run: New-Item -ItemType directory -Path ..\..\Squirrelies
# Checkout latest dependencies code
- name: Checkout SRTHost
uses: actions/checkout@v2
with:
fetch-depth: 0
path: SRTHost
repository: Squirrelies/SRTHost
# GITHUB_WORKSPACE pathing is ass. Move this directory down one level.
- name: Move SRTHost down a folder to work with existing csproj pathing
run: Move-Item -Path SRTHost -Destination ..\..\Squirrelies
# Checkout latest dependencies code
- name: Checkout ProcessMemory
uses: actions/checkout@v2
with:
fetch-depth: 0
path: ProcessMemory
repository: Squirrelies/ProcessMemory
# GITHUB_WORKSPACE pathing is ass. Move this directory down one level.
- name: Move ProcessMemory down a folder to work with existing csproj pathing
run: Move-Item -Path ProcessMemory -Destination ..\..\Squirrelies
# Set some output variables
- name: Set the main environment variables based on other environment variables
id: generated-variables-1
run: |
echo '::set-output name=solution::${{env.project-name}}.sln'
echo '::set-output name=project::${{env.project-name}}/${{env.project-name}}.csproj'
echo '::set-output name=build-directory::${{env.project-name}}/bin/${{env.platform}}/Release/net5.0/'
# Get the project's version number
- name: Get project version
id: get_version
uses: greenygh0st/net-proj-release-version@v1
with:
PROJ_FILE: ${{steps.generated-variables-1.outputs.project}}
# Sets the zip-filename output variable based on the project version
- name: Sets the zip-filename environment variable based on the project version
id: generated-variables-2
run: |
echo '::set-output name=zip-filename::${{env.project-name}}-v${{steps.get_version.outputs.RELEASE_VERSION}}.zip'
# Install .NET
- name: Install .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
# Compiles the plugin
- name: Compile the plugin
run: |
dotnet build ${{steps.generated-variables-1.outputs.solution}} -c "${{env.configuration}}" /p:Platform="${{env.platform}}"
- name: Upload publish artifacts
uses: actions/upload-artifact@v2
with:
path: |
${{steps.generated-variables-1.outputs.build-directory}}*
release:
name: "Release"
runs-on: "windows-latest"
needs: build
env:
working-directory: .
is-prerelease: true
steps:
# Checkout latest code
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v2
# Zip the publish artifacts
- name: Zip the publish artifacts
run: |
Add-Type -assembly 'System.IO.Compression'
Add-Type -assembly 'System.IO.Compression.FileSystem'
[System.IO.Compression.ZipArchive]$zipFile = [System.IO.Compression.ZipFile]::Open('${{needs.build.outputs.zip-filename}}', ([System.IO.Compression.ZipArchiveMode]::Create))
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, 'LICENSE', '${{needs.build.outputs.project-name}}\LICENSE')
$filesToZip = (Get-ChildItem -Path artifact -File -Recurse).FullName
foreach ($fileToZip in $filesToZip) {
$fileNameInZip = $fileToZip.Replace(($pwd.Path + '\artifact\'),'')
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zipFile, $fileToZip, ('${{needs.build.outputs.project-name}}\' + $fileNameInZip))
}
$zipFile.Dispose()
# Pushes the release
- name: Publish release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: ${{env.is-prerelease}}
title: 'Automated Build - ${{needs.build.outputs.version}} Release'
files: |
${{needs.build.outputs.zip-filename}}