-
Notifications
You must be signed in to change notification settings - Fork 96
155 lines (141 loc) · 5.44 KB
/
dotnet-core.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
name: .NET Core
on:
workflow_dispatch:
push:
branches: [ master ]
tags: '*'
paths:
- "**"
- "!**.MD"
- "!**.md"
- "!LICENSE"
- "!.gitignore"
- "!.github/workflows/**"
pull_request:
branches: [ master ]
paths:
- "**"
- "!**.MD"
- "!**.md"
- "!LICENSE"
- "!.gitignore"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Publish
run: dotnet publish --configuration Release --no-build --output ./.github/out
- name: Delete extra files
run: rm -f ./.github/out/aliyun-ddns ./.github/out/aliyun-ddns.pdb
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2
with:
path: ./.github/out
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Prepare
id: prepare
run: |
echo ::set-output name=docker_platforms::linux/amd64,linux/arm/v7,linux/arm64
echo ::set-output name=docker_image::${{ secrets.DOCKER_HUB_USER }}/aliyun-ddns
- name: Docker Buildx (no push)
run: |
docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64 \
--output "type=image,push=false" \
--file ./.github/Dockerfile ./.github
- name: Docker Hub Login
if: success() && !startsWith(github.event_name, 'pull_request')
run: |
docker login --username "${{ secrets.DOCKER_HUB_USER }}" -p ${{ secrets.DOCKER_HUB_PASS }}
- name: Docker Buildx (push)
if: success() && !startsWith(github.event_name, 'pull_request')
run: |
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \
--push \
--tag "${{ steps.prepare.outputs.docker_image }}:latest" \
--file ./.github/Dockerfile ./.github
docker buildx build --platform linux/amd64 \
--push \
--tag "${{ steps.prepare.outputs.docker_image }}:linux-amd64" \
--file ./.github/Dockerfile ./.github
docker buildx build --platform linux/arm64 \
--push \
--tag "${{ steps.prepare.outputs.docker_image }}:linux-arm64v8" \
--file ./.github/Dockerfile ./.github
docker buildx build --platform linux/arm/v7 \
--push \
--tag "${{ steps.prepare.outputs.docker_image }}:linux-arm32v7" \
--file ./.github/Dockerfile ./.github
- name: Docker Buildx (push on tags)
if: success() && startsWith(github.ref, 'refs/tags')
run: |
docker buildx build --platform ${{ steps.prepare.outputs.docker_platforms }} \
--push \
--tag "${{ steps.prepare.outputs.docker_image }}:${GITHUB_REF#refs/tags/}" \
--file ./.github/Dockerfile ./.github
docker buildx build --platform linux/amd64 \
--push \
--tag "${{ steps.prepare.outputs.docker_image }}:${GITHUB_REF#refs/tags/}-linux-amd64" \
--file ./.github/Dockerfile ./.github
docker buildx build --platform linux/arm64 \
--push \
--tag "${{ steps.prepare.outputs.docker_image }}:${GITHUB_REF#refs/tags/}-linux-arm64v8" \
--file ./.github/Dockerfile ./.github
docker buildx build --platform linux/arm/v7 \
--push \
--tag "${{ steps.prepare.outputs.docker_image }}:${GITHUB_REF#refs/tags/}-linux-arm32v7" \
--file ./.github/Dockerfile ./.github
- name: Docker Check Manifest
if: success() && !startsWith(github.event_name, 'pull_request')
run: |
docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:latest
- name: Clear
if: always() && !startsWith(github.event_name, 'pull_request')
run: |
rm -f ${HOME}/.docker/config.json
- name: Prepare
if: success() && startsWith(github.ref, 'refs/tags')
id: zipname
run: |
echo ::set-output name=zip_name::aliyun-ddns-${GITHUB_REF#refs/tags/}.zip
echo ::set-output name=version::${GITHUB_REF#refs/tags/}
- name: Create zip
if: success() && startsWith(github.ref, 'refs/tags')
run: |
zip --junk-paths -q -r ${{ steps.zipname.outputs.zip_name }} ./.github/out/*
- name: Create Release
if: success() && startsWith(github.ref, 'refs/tags')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.zipname.outputs.version }}
release_name: ${{ steps.zipname.outputs.version }}
draft: false
prerelease: false
- name: Upload Release Asset
if: success() && startsWith(github.ref, 'refs/tags')
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ steps.zipname.outputs.zip_name }}
asset_name: ${{ steps.zipname.outputs.zip_name }}
asset_content_type: application/zip