-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (56 loc) · 2.21 KB
/
pack-and-publish.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
name: publish
on:
push:
branches: ["main"]
tags: ["v*.*.*"] # Publish semver tags as releases.
pull_request:
branches: ["main"]
jobs:
build-and-test:
environment: Test
runs-on: ubuntu-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 src/Hooki
- name: Build
run: dotnet build src/Hooki --configuration Release --no-restore
- name: Run Unit Tests
run: dotnet test src/Hooki.UnitTests/Hooki.UnitTests.csproj --no-restore
- name: Run Integration Tests
env:
DOTNET_ENVIRONMENT: ${{ vars.DOTNET_ENVIRONMENT }}
TEST_DISCORD_WEBHOOK_URL: ${{ secrets.TEST_DISCORD_WEBHOOK_URL }}
TEST_MICROSOFT_TEAMS_WEBHOOK_URL: ${{ secrets.TEST_MICROSOFT_TEAMS_WEBHOOK_URL }}
TEST_SLACK_WEBHOOK_URL: ${{ secrets.TEST_SLACK_WEBHOOK_URL }}
TEST_PIPEDREAM_URL: ${{ secrets.TEST_PIPEDREAM_URL }}
TEST_IMAGE_FILE_NAME: ${{ vars.TEST_IMAGE_FILE_NAME }}
TEST_IMAGE_CLOUD_URL: ${{ secrets.TEST_IMAGE_CLOUD_URL }}
run: dotnet test src/Hooki.IntegrationTests/Hooki.IntegrationTests.csproj --no-restore
pack-and-publish:
needs: build-and-test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-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 src/Hooki
- name: Build
run: dotnet build src/Hooki --configuration Release --no-restore
- name: Set version and trim leading 'v'
run: |
version=$(echo ${{ github.ref_name }} | sed 's/^v//')
echo "VERSION=$version" >> $GITHUB_ENV
echo "Set VERSION to $version"
- name: Pack
run: dotnet pack src/Hooki/Hooki.csproj --configuration Release --no-build -p:PackageVersion=${{env.VERSION}} --output ./nupkgs
- name: Publish to NuGet
run: dotnet nuget push "./nupkgs/Hooki.*" --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate