-
-
Notifications
You must be signed in to change notification settings - Fork 33
163 lines (133 loc) · 5.02 KB
/
dotnet.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
name: .NET
on: push
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c release
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Min
run: >
dotnet publish -c release -p:PublishDir=../dist/min --no-self-contained
-p:PublishSingleFile=true -p:DebugType=embedded -p:PublishTrimmed=false
-p:EnableCompressionInSingleFile=false --use-current-runtime Elib2EbookCli
- name: Portable
run: >
dotnet publish -c release -p:PublishDir=../dist/portable --self-contained
-p:PublishSingleFile=true -p:DebugType=embedded
-p:EnableCompressionInSingleFile=true --use-current-runtime Elib2EbookCli
- uses: actions/upload-artifact@v4
with:
name: Elib2Ebook-${{ matrix.os }}-min
path: ${{ github.workspace }}/dist/min
- uses: actions/upload-artifact@v4
with:
name: Elib2Ebook-${{ matrix.os }}-portable
path: ${{ github.workspace }}/dist/portable
check_version:
name: Check version
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
outputs:
VERSION: ${{ steps.get-version.outputs.version }}
LAST_TAG: ${{ steps.last_release.outputs.tag_name }}
steps:
- name: check repository
uses: actions/checkout@v4
- uses: kzrnm/get-net-sdk-project-versions-action@v2
id: get-version
with:
proj-path: Core/Core.csproj
- name: "get-last-release"
id: last_release
uses: InsonusK/[email protected]
with:
myToken: ${{ github.token }}
push_to_registry:
name: push docker image to hub
runs-on: ubuntu-latest
needs: check_version
if: ${{ needs.check_version.outputs.LAST_TAG != needs.check_version.outputs.VERSION }}
strategy:
matrix:
folder: [ Elib2EbookCli, Elib2EbookWeb ]
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: check repository
uses: actions/checkout@v4
- name: login to docker registry
uses: docker/login-action@v3
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- id: string
uses: ASzc/change-string-case-action@v6
with:
string: ${{ matrix.folder }}
- name: build and push docker image to registry
uses: docker/build-push-action@v6
with:
platforms: linux/amd64, linux/arm64
file: "${{ matrix.folder }}/Dockerfile"
push: true
tags: ${{secrets.DOCKERHUB_NAMESPACE}}/${{ steps.string.outputs.lowercase }}:${{ needs.check_version.outputs.VERSION }},${{secrets.DOCKERHUB_NAMESPACE}}/${{ steps.string.outputs.lowercase }}:latest
create_release:
needs: check_version
runs-on: ubuntu-latest
if: ${{ needs.check_version.outputs.LAST_TAG != needs.check_version.outputs.VERSION }}
outputs:
UPLOAD_URL: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: ${{needs.check_version.outputs.VERSION}}
tag_name: ${{needs.check_version.outputs.VERSION}}
env:
GITHUB_TOKEN: ${{ github.token }}
upload_release:
needs: create_release
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
version: [ min, portable ]
steps:
- name: download-artifact-${{ matrix.os }}-${{ matrix.version }}
uses: actions/download-artifact@v4
with:
name: Elib2Ebook-${{ matrix.os }}-${{ matrix.version }}
path: ${{ github.workspace }}/${{ matrix.os }}-${{ matrix.version }}
- name: Install zip
uses: montudor/[email protected]
- name: Zip output
run: zip -qq -x "*.pdb" -r ../Elib2Ebook-${{ matrix.os }}-${{ matrix.version }}.zip .
working-directory: ${{ github.workspace }}/${{ matrix.os }}-${{ matrix.version }}
- name: upload ${{ matrix.os }}-${{ matrix.version }} asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.create_release.outputs.UPLOAD_URL }}
asset_path: Elib2Ebook-${{ matrix.os }}-${{ matrix.version }}.zip
asset_name: Elib2Ebook-${{ matrix.os }}-${{ matrix.version }}.zip
asset_content_type: application/zip