-
Notifications
You must be signed in to change notification settings - Fork 2
177 lines (154 loc) · 6.79 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: CI
on:
push:
tags:
- "*.*.*"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x.x'
- name: Restore dependencies
run: dotnet restore
- name: Build application
run: dotnet build --configuration Release
- name: Test application
run: dotnet test
matrix-build:
needs: build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
RUNTIME: linux-x64
- os: windows-latest
RUNTIME: win-x64
- os: macos-latest
RUNTIME: osx-x64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set version from branch name
id: set_version
shell: bash
run: |
version=$(echo "${{ github.ref_name }}")
version=$(echo $version | tr '[:upper:]' '[:lower:]')
echo "version=$version" >> $GITHUB_OUTPUT
major_version=$(echo $version | cut -d '.' -f 1)
minor_version=$(echo $version | cut -d '.' -f 2)
echo "major_version=$major_version" >> $GITHUB_OUTPUT
echo "minor_version=$minor_version" >> $GITHUB_OUTPUT
lowercase=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "image_name=$lowercase" >> $GITHUB_OUTPUT
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x.x'
- name: Restore dependencies
run: dotnet restore
- name: Build application
run: dotnet publish VRLabs.VRCTools.Packaging.Console --configuration Release --output bin/Release/publish --runtime ${{ matrix.RUNTIME }} --self-contained false /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true /p:DebugType=Embedded /p:Version=${{ steps.set_version.outputs.version }}
- name: Rename executable
shell: bash
run: |
mv bin/Release/publish/VRLabs.VRCTools.Packaging.Console bin/Release/publish/VRCPackagingTool${1##*.}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: VRCPackagingTool-${{ matrix.RUNTIME }}
path: bin/Release/publish/
retention-days: 1
docker-build:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set version from branch name
id: set_version
run: |
version=$(echo "${{ github.ref_name }}")
version=$(echo $version | tr '[:upper:]' '[:lower:]')
echo "version=$version" >> $GITHUB_OUTPUT
major_version=$(echo $version | cut -d '.' -f 1)
minor_version=$(echo $version | cut -d '.' -f 2)
echo "major_version=$major_version" >> $GITHUB_OUTPUT
echo "minor_version=$minor_version" >> $GITHUB_OUTPUT
lowercase=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "image_name=$lowercase" >> $GITHUB_OUTPUT
- name: Set project version
run: |
sed -i "s/<Version>.*<\/Version>/<Version>${{ steps.set_version.outputs.version }}<\/Version>/" VRLabs.VRCTools.Packaging/VRLabs.VRCTools.Packaging.csproj
sed -i "s/<Version>.*<\/Version>/<Version>${{ steps.set_version.outputs.version }}<\/Version>/" VRLabs.VRCTools.Packaging.Console/VRLabs.VRCTools.Packaging.Console.csproj
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./VRLabs.VRCTools.Packaging.Console/Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ steps.set_version.outputs.image_name }}:${{ steps.set_version.outputs.version }}
${{ env.REGISTRY }}/${{ steps.set_version.outputs.image_name }}:${{ steps.set_version.outputs.major_version }}.${{ steps.set_version.outputs.minor_version }}
${{ env.REGISTRY }}/${{ steps.set_version.outputs.image_name }}:${{ steps.set_version.outputs.major_version }}
${{ env.REGISTRY }}/${{ steps.set_version.outputs.image_name }}:latest
release:
needs: [matrix-build, docker-build]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set version from branch name
id: set_version
run: |
version=$(echo "${{ github.ref_name }}")
version=$(echo $version | tr '[:upper:]' '[:lower:]')
echo "version=$version" >> $GITHUB_OUTPUT
major_version=$(echo $version | cut -d '.' -f 1)
minor_version=$(echo $version | cut -d '.' -f 2)
echo "major_version=$major_version" >> $GITHUB_OUTPUT
echo "minor_version=$minor_version" >> $GITHUB_OUTPUT
lowercase=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "image_name=$lowercase" >> $GITHUB_OUTPUT
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: bin/Release/publish
- name: Zip each artifact
run: |
cd bin/Release/publish/VRCPackagingTool-linux-x64
zip -r ../VRCPackagingTool-linux-x64.zip .
cd ../VRCPackagingTool-win-x64
zip -r ../VRCPackagingTool-win-x64.zip .
cd ../VRCPackagingTool-osx-x64
zip -r ../VRCPackagingTool-osx-x64.zip .
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SOURCE_TAG: ${{ steps.set_version.outputs.version }}
with:
name: Release ${{ steps.set_version.outputs.version }}
files: |
bin/Release/publish/VRCPackagingTool-linux-x64.zip
bin/Release/publish/VRCPackagingTool-win-x64.zip
bin/Release/publish/VRCPackagingTool-osx-x64.zip