-
Notifications
You must be signed in to change notification settings - Fork 3
127 lines (105 loc) · 3.61 KB
/
release.yml
File metadata and controls
127 lines (105 loc) · 3.61 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
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
name: Deploy Release
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
tag:
description: 'Git tag to release (e.g. v1.2.3 or v1.2.3-beta.1)'
required: true
type: string
dry_run:
description: 'Dry run (skip Docker + NuGet push)'
required: true
default: 'true'
type: choice
options:
- 'true'
- 'false'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Determine Release Version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
RAW_VERSION="${{ inputs.tag }}"
DRY_RUN="${{ inputs.dry_run }}"
else
RAW_VERSION="${GITHUB_REF##*/}"
DRY_RUN="false"
fi
CLEAN_VERSION="${RAW_VERSION#v}"
if [[ "${CLEAN_VERSION}" == *"beta"* ]]; then
IMAGE_TAG="beta"
PUSH_CLEAN_VERSION="false"
else
IMAGE_TAG="latest"
PUSH_CLEAN_VERSION="true"
fi
if [[ "${DRY_RUN}" == "true" ]]; then
PUSH_DOCKER="false"
PUSH_NUGET="false"
else
PUSH_DOCKER="true"
PUSH_NUGET="true"
fi
echo "RAW_VERSION=$RAW_VERSION" >> $GITHUB_ENV
echo "CLEAN_VERSION=$CLEAN_VERSION" >> $GITHUB_ENV
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
echo "PUSH_CLEAN_VERSION=$PUSH_CLEAN_VERSION" >> $GITHUB_ENV
echo "PUSH_DOCKER=$PUSH_DOCKER" >> $GITHUB_ENV
echo "PUSH_NUGET=$PUSH_NUGET" >> $GITHUB_ENV
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --configuration Release /p:Version=${{ env.CLEAN_VERSION }}
- name: Test
run: dotnet test --configuration Release /p:Version=${{ env.CLEAN_VERSION }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Frontend Dependencies
working-directory: src/LogPort.UI
run: npm ci
- name: Build Frontend
working-directory: src/LogPort.UI
run: npm run build
- name: Pack SDKs
run: dotnet pack -c Release --no-build /p:Version=${{ env.CLEAN_VERSION }} /p:PackageVersion=${{ env.CLEAN_VERSION }} -o ./artifacts
- name: Push SDK to NuGet
if: ${{ env.PUSH_NUGET == 'true' }}
run: dotnet nuget push "./artifacts/*.nupkg" \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
- name: Log in to Docker Hub
if: ${{ env.PUSH_DOCKER == 'true' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and Push Docker Image
if: ${{ env.PUSH_DOCKER == 'true' }}
uses: docker/build-push-action@v5
with:
context: .
file: ./src/LogPort.Agent/Dockerfile
push: true
tags: |
thiagomvas/logport:${{ env.IMAGE_TAG }}
- name: Push immutable Docker tag
if: ${{ env.PUSH_CLEAN_VERSION == 'true' && env.PUSH_DOCKER == 'true' }}
run: |
docker tag thiagomvas/logport:${{ env.IMAGE_TAG }} thiagomvas/logport:${{ env.CLEAN_VERSION }}
docker push thiagomvas/logport:${{ env.CLEAN_VERSION }}