Skip to content

Commit 3cd85af

Browse files
authored
Merge pull request #2 from bcc-code:use-trusted-publishing
use trusted publishing
2 parents f99ce12 + 6f73ad6 commit 3cd85af

1 file changed

Lines changed: 41 additions & 34 deletions

File tree

.github/workflows/hailey-sdk-dotnet-nuget.yml

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,51 @@ name: Publish Nuget Package
22

33
on:
44
push:
5-
branches: [ master, main ]
5+
branches: [master, main]
66
pull_request:
7-
branches: [ master, main ]
7+
branches: [master, main]
88

9-
env:
10-
API_KEY: ${{ secrets.NUGET_PACKAGES_GITHUB_API_KEY }}
11-
129
jobs:
1310
build:
14-
1511
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write
1615

1716
steps:
18-
- uses: actions/checkout@v2
19-
- name: Setup .NET
20-
uses: actions/setup-dotnet@v1
21-
with:
22-
dotnet-version: 7.0.x
23-
24-
- name: Set Environment Variables
25-
uses: ./.github/actions/setvars
26-
with:
27-
varFilePath: ./.github/variables/version.env
28-
29-
- name: Set package version
30-
run: |
31-
if [[ $GITHUB_REF == 'refs/heads/main' && $GITHUB_EVENT_NAME == 'push' ]]; then
32-
echo "VERSION=${{ env.VERSION }}.${{ github.run_number}}" >> "$GITHUB_ENV"
33-
else
34-
echo "VERSION=${{ env.VERSION }}.${{ github.run_number}}-beta" >> "$GITHUB_ENV"
35-
fi
36-
37-
- name: Package
38-
working-directory: BccCode.Hailey.Client
39-
run: |
40-
dotnet pack -p:PackageVersion=${{ env.VERSION }} -c Release -o . BccCode.Hailey.Client.csproj -p:GeneratePackageOnBuild=false
41-
42-
- name: Publish
43-
working-directory: BccCode.Hailey.Client
44-
run: |
45-
dotnet nuget push BccCode.Hailey.Client*.nupkg -k ${{env.API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate
17+
- uses: actions/checkout@v2
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v1
20+
with:
21+
dotnet-version: 7.0.x
22+
23+
- name: Set Environment Variables
24+
uses: ./.github/actions/setvars
25+
with:
26+
varFilePath: ./.github/variables/version.env
27+
28+
- name: Set package version
29+
run: |
30+
if [[ $GITHUB_REF == 'refs/heads/main' && $GITHUB_EVENT_NAME == 'push' ]]; then
31+
echo "VERSION=${{ env.VERSION }}.${{ github.run_number}}" >> "$GITHUB_ENV"
32+
else
33+
echo "VERSION=${{ env.VERSION }}.${{ github.run_number}}-beta" >> "$GITHUB_ENV"
34+
fi
35+
36+
- name: Package
37+
working-directory: BccCode.Hailey.Client
38+
run: |
39+
dotnet pack -p:PackageVersion=${{ env.VERSION }} -c Release -o . BccCode.Hailey.Client.csproj -p:GeneratePackageOnBuild=false
40+
41+
- uses: NuGet/login@v1
42+
id: login
43+
with:
44+
user: ${{vars.NUGET_USER}}
45+
46+
- name: Publish
47+
working-directory: BccCode.Hailey.Client
48+
run: |
49+
dotnet nuget push BccCode.Hailey.Client*.nupkg \
50+
--api-key ${{ steps.login.outputs.NUGET_API_KEY }} \
51+
--source https://api.nuget.org/v3/index.json \
52+
--skip-duplicate

0 commit comments

Comments
 (0)