-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (85 loc) · 2.81 KB
/
release-web.yml
File metadata and controls
101 lines (85 loc) · 2.81 KB
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
name: Release Web
on:
workflow_dispatch:
jobs:
validate:
name: Validate version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.read_version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Read version from semver.txt
id: read_version
run: |
version=$(tr -d '[:space:]' < src/CoderPatros.Tea.Web/semver.txt)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Validate semver format
run: |
if ! echo "${{ steps.read_version.outputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$'; then
echo "::error::Version '${{ steps.read_version.outputs.version }}' is not valid semver"
exit 1
fi
- name: Check tag does not exist
run: |
if git ls-remote --tags https://github.com/${{ github.repository }} | grep -q "refs/tags/web/v${{ steps.read_version.outputs.version }}$"; then
echo "::error::Tag web/v${{ steps.read_version.outputs.version }} already exists"
exit 1
fi
test:
name: Test (${{ matrix.os }})
needs: validate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
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
- name: Test
run: dotnet test --no-build --verbosity normal
release:
name: Release
needs: [validate, test]
runs-on: ubuntu-latest
permissions:
contents: write
env:
VERSION: ${{ needs.validate.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: src/CoderPatros.Tea.Web/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
coderpatros/tea-web:${{ env.VERSION }}
coderpatros/tea-web:latest
- name: Create and push tag
run: |
git tag "web/v${{ env.VERSION }}"
git push origin "web/v${{ env.VERSION }}"
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: web/v${{ env.VERSION }}
name: Web v${{ env.VERSION }}
generate_release_notes: true