-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (56 loc) · 2.35 KB
/
nuget-ci-cd.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
name: Build NuGet packages
on:
push:
branches: [ develop, main ]
tags:
- v*
pull_request:
branches: [ develop, main ]
jobs:
build:
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# We use `git describe` to find tags in commit history, so we need complete repo history
fetch-depth: 0
- name: Calculate version number for PR build
if: github.event_name == 'pull_request'
shell: bash
run: src/calculate-version.sh "${{ github.run_number }}" "${{ github.event.number }}"
- name: Calculate version number for non-PR build
if: github.event_name != 'pull_request'
shell: bash
run: src/calculate-version.sh "${{ github.run_number }}"
- name: Install .NET
uses: actions/setup-dotnet@v4
- name: Build & test
run: dotnet test --configuration Release --logger GitHubActions
- name: Pack
shell: bash
run: |
dotnet pack --include-symbols /p:PackageVersion="$PACKAGE_VERSION" /p:AssemblyVersion="$ASSEMBLY_VERSION" /p:FileVersion="$FILE_VERSION"
- name: Upload packages to build artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: src/artifacts/package/release/*nupkg
# Not using the GitHub package registry right now, since it doesn't allow anonymous access so it's a hassle to use
# - name: Publish package to GitHub
# if: github.event_name == 'pull_request' || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads'))
# shell: bash
# run: |
# dotnet nuget push "src/artifacts/package/release/*.symbols.nupkg" -s https://nuget.pkg.github.com/sillsdev/index.json -k "$NUGET_API_KEY" --skip-duplicate
# env:
# NUGET_API_KEY: ${{ secrets.GITHUB_TOKEN }}
# - name: Publish package to NuGet.org
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
# shell: bash
# run: |
# echo Would run the following:
# echo dotnet nuget push "src/artifacts/package/release/*nupkg" --skip-duplicate --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json
# env:
# NUGET_API_KEY: ${{ secrets.SILLSDEV_PUBLISH_NUGET_ORG }}