-
-
Notifications
You must be signed in to change notification settings - Fork 3
159 lines (132 loc) · 5.2 KB
/
CI.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
name: CI
on: push
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
build:
runs-on: windows-latest
name: Build and Test
env:
CONFIGURATION: Release
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
- name: Restore Dependencies
run: |
dotnet tool install -g dotnet-version-cli
dotnet restore
# dotnet version --dry-run -f src/Common.props --build-meta { git rev-parse --short HEAD }
- run: dotnet build -c $env:CONFIGURATION
- run: dotnet build -c $env:CONFIGURATION src\HolzShots\HolzShots.csproj
- run: dotnet test -c $env:CONFIGURATION --no-build src\HolzShots.Core.Tests\HolzShots.Core.Tests.csproj
- run: npm install -g ajv-cli
# - name: Validate JSON Schemas
# run: |
# curl -o json-schema.json https://json-schema.org/draft/2019-09/schema
# ajv -s json-schema.json -d src/schema/*.schema.json
- name: Collect Artifacts
if: startsWith(github.ref, 'refs/tags/v')
run: |
7z a HolzShots.zip ".\src\HolzShots\bin\$env:CONFIGURATION\net9.0-windows\win-x64\*.exe"
7z a HolzShots.zip ".\src\HolzShots\bin\$env:CONFIGURATION\net9.0-windows\win-x64\*.dll"
7z a HolzShots.zip ".\src\HolzShots\bin\$env:CONFIGURATION\net9.0-windows\win-x64\*.config"
7z a HolzShots.zip ".\src\HolzShots\bin\$env:CONFIGURATION\net9.0-windows\win-x64\*.manifest"
sha256sum HolzShots.zip > sha256sums.txt
- uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/v')
with:
name: HolzShots.zip
path: HolzShots.zip
- uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/v')
with:
name: sha256sums.txt
path: sha256sums.txt
release:
runs-on: windows-latest
needs: [build]
name: Publish Release
if: startsWith(github.ref, 'refs/tags/v')
env:
CONFIGURATION: Release
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: HolzShots.zip
path: .
- uses: actions/download-artifact@v4
with:
name: sha256sums.txt
path: .
- name: Perpare Version Data
shell: bash
run: |
RELEASE_VERSION=${GITHUB_REF#refs/tags/v}
RELEASE_YEAR=`date +"%Y"`
RELEASE_HASH=`grep -ohiE "^[0-9a-z]+" sha256sums.txt`
echo "version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
echo "year=${RELEASE_YEAR}" >> $GITHUB_OUTPUT
echo "checksum=${RELEASE_HASH}" >> $GITHUB_OUTPUT
sed -i -e "s/__REPLACE_YEAR__/${RELEASE_YEAR}/g" package/holzshots.nuspec
sed -i -e "s/__REPLACE_VERSION__/${RELEASE_VERSION}/g" package/holzshots.nuspec
sed -i -e "s/__REPLACE_VERSION__/${RELEASE_VERSION}/g" package/tools/chocolateyinstall.ps1
sed -i -e "s/__REPLACE_CHECKSUM__/${RELEASE_HASH}/g" package/tools/chocolateyinstall.ps1
- name: Bundle Chocolatey Package
uses: crazy-max/[email protected]
with:
args: pack --out . ./package/holzshots.nuspec
# https://github.com/actions/upload-artifact/issues/11#issuecomment-568101677
- id: get_choco_package
shell: bash
run: echo "file=$(ls holzshots*.nupkg)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: holzshots.nupkg
path: ${{ steps.get_choco_package.outputs.file }}
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset HolzShots.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./HolzShots.zip
asset_name: HolzShots.zip
asset_content_type: application/zip
- name: Upload Release Asset sha256sums.txt
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./sha256sums.txt
asset_name: sha256sums.txt
asset_content_type: text/plain
- name: Upload Release Asset Chocolatey-Package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.get_choco_package.outputs.file }}
asset_name: ${{ steps.get_choco_package.outputs.file }}
asset_content_type: application/zip
- name: Publish Chocolatey Package to Community Feed
shell: bash
run: |
choco push ${{ steps.get_choco_package.outputs.file }} --source "https://push.chocolatey.org/" -k="${{ secrets.CHOCO_API_KEY }}"