Skip to content

Commit 11141df

Browse files
authored
Merge pull request #106 from SteeltoeOSS/gha
Move from Azure DevOps to GitHub Actions
2 parents ab0ef7c + 8106c5d commit 11141df

File tree

6 files changed

+160
-130
lines changed

6 files changed

+160
-130
lines changed

.github/workflows/build.yml

Lines changed: 159 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
1-
name: build-and-test
1+
name: BuildTestDeploy
22
on:
3-
pull_request:
4-
branches:
5-
- main
3+
workflow_dispatch:
64
push:
75
branches:
86
- main
9-
workflow_dispatch: {}
7+
- 'release/*'
8+
pull_request:
9+
release:
10+
types:
11+
- published
12+
schedule:
13+
# Run this workflow at 6 PM UTC every Sunday
14+
- cron: "0 18 * * *"
1015

1116
concurrency:
12-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
17+
group: ${{ github.workflow }}-${{ github.ref }}
1318
cancel-in-progress: true
1419

20+
permissions:
21+
contents: read
22+
1523
env:
24+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
1625
DOTNET_NOLOGO: true
17-
DOTNET_CLI_TELEMETRY_OPTOUT: true
1826

1927
jobs:
2028
build-and-test:
21-
timeout-minutes: 60
29+
name: Build, Test and Package
30+
timeout-minutes: 20
2231
strategy:
2332
fail-fast: false
2433
matrix:
2534
os: [ubuntu-latest, windows-latest, macos-latest]
2635
runs-on: ${{ matrix.os }}
36+
2737
steps:
2838
- name: Setup .NET
2939
uses: actions/setup-dotnet@v4
@@ -32,29 +42,154 @@ jobs:
3242
6.0.*
3343
8.0.*
3444
9.0.*
45+
3546
- name: Git checkout
3647
uses: actions/checkout@v4
3748
with:
3849
fetch-depth: 0
50+
3951
- name: Restore tools
40-
run: |
41-
dotnet tool restore
52+
run: dotnet tool restore
53+
4254
- name: Restore packages
43-
run: |
44-
dotnet restore
45-
- name: Build
46-
run: |
47-
dotnet build --no-restore --configuration Release
55+
run: dotnet restore --verbosity minimal
56+
57+
- name: Build solution
58+
run: dotnet build --no-restore --configuration Release --verbosity minimal
59+
4860
- name: Test
49-
run: |
50-
dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
51-
- name: Generate packages
61+
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --logger "GitHubActions;summary.includeSkippedTests=true"
62+
63+
- name: Collect packages
5264
shell: pwsh
53-
run: |
54-
dotnet pack src --no-build --configuration Release --output $env:GITHUB_WORKSPACE/artifacts/packages
55-
- name: Upload packages to artifacts
56-
if: matrix.os == 'ubuntu-latest'
65+
run: dotnet pack src --no-build --configuration Release --output ${{ github.workspace }}/packages
66+
67+
- name: Upload unsigned packages
68+
if: ${{ matrix.os == 'ubuntu-latest' }}
5769
uses: actions/upload-artifact@v4
5870
with:
59-
name: packages
60-
path: artifacts/packages
71+
if-no-files-found: error
72+
name: unsigned-packages
73+
path: ${{ github.workspace }}/packages/**/*.nupkg
74+
75+
sign:
76+
name: Sign
77+
if: ${{ github.event_name != 'pull_request' }}
78+
timeout-minutes: 15
79+
needs: build-and-test
80+
runs-on: windows-latest
81+
environment: signing
82+
permissions:
83+
id-token: write
84+
85+
steps:
86+
- name: Download unsigned packages
87+
uses: actions/download-artifact@v4
88+
with:
89+
name: unsigned-packages
90+
path: packages
91+
92+
- name: Setup .NET
93+
uses: actions/setup-dotnet@v4
94+
with:
95+
dotnet-version: 8.0.*
96+
97+
- name: Install code signing tool
98+
run: dotnet tool install --global sign --prerelease
99+
100+
- name: Azure login
101+
uses: azure/login@v2
102+
with:
103+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
104+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
105+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
106+
107+
- name: Sign packages
108+
run: >-
109+
sign code azure-key-vault '**/*.nupkg'
110+
--base-directory '${{ github.workspace }}/packages'
111+
--azure-key-vault-managed-identity true
112+
--azure-credential-type 'azure-cli'
113+
--azure-key-vault-url '${{ secrets.AZURE_KEY_VAULT_URL }}'
114+
--azure-key-vault-certificate '${{ secrets.AZURE_SIGN_CERTIFICATE_ID }}'
115+
--publisher-name 'Steeltoe'
116+
--description 'Steeltoe'
117+
--description-url 'https://steeltoe.io/'
118+
119+
- name: Upload signed packages
120+
uses: actions/upload-artifact@v4
121+
with:
122+
if-no-files-found: error
123+
name: signed-packages
124+
path: ${{ github.workspace }}/packages/**/*.nupkg
125+
126+
dev-feed-deploy:
127+
name: Deploy packages to development feed
128+
timeout-minutes: 15
129+
needs: sign
130+
if: ${{ github.event_name != 'pull_request' }}
131+
environment: azdo
132+
runs-on: ubuntu-latest
133+
permissions:
134+
id-token: write
135+
env:
136+
VSS_NUGET_URI_PREFIXES: https://pkgs.dev.azure.com/dotnet/
137+
138+
steps:
139+
- name: Azure login
140+
uses: azure/login@v2
141+
with:
142+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
143+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
144+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
145+
146+
- name: Download signed packages
147+
uses: actions/download-artifact@v4
148+
with:
149+
name: signed-packages
150+
path: packages
151+
152+
- name: Setup .NET
153+
uses: actions/setup-dotnet@v4
154+
with:
155+
dotnet-version: 8.0.x
156+
source-url: ${{ vars.AZURE_ARTIFACTS_FEED_URL }}
157+
env:
158+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159+
160+
- name: Install credential provider for Azure Artifacts
161+
run: sh -c "$(curl -fsSL https://aka.ms/install-artifacts-credprovider.sh)"
162+
163+
- name: Extract access token
164+
run: |
165+
accessToken=$(az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv)
166+
echo "::add-mask::$accessToken"
167+
echo "ACCESS_TOKEN=$accessToken" >> $GITHUB_ENV
168+
169+
- name: Configure authentication provider to use Azure DevOps token
170+
run: echo "VSS_NUGET_ACCESSTOKEN=$ACCESS_TOKEN" >> $GITHUB_ENV
171+
172+
- name: Push packages to Azure Artifacts
173+
run: dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --api-key 'azdo-placeholder' --source '${{ vars.AZURE_ARTIFACTS_FEED_URL }}'
174+
175+
nuget-org-deploy:
176+
name: Deploy packages to nuget.org
177+
needs: sign
178+
if: ${{ github.event_name == 'release' }}
179+
environment: nuget.org
180+
runs-on: ubuntu-latest
181+
182+
steps:
183+
- name: Setup .NET
184+
uses: actions/setup-dotnet@v4
185+
with:
186+
dotnet-version: 8.0.x
187+
188+
- name: Download signed packages
189+
uses: actions/download-artifact@v4
190+
with:
191+
name: signed-packages
192+
path: packages
193+
194+
- name: Push packages to nuget.org
195+
run: dotnet nuget push '${{ github.workspace }}/packages/*.nupkg' --skip-duplicate --api-key ${{ secrets.STEELTOE_NUGET_API_KEY }} --source 'nuget.org'

azure-pipelines.yaml

Lines changed: 0 additions & 61 deletions
This file was deleted.

sign/SignPackages.ps1

Lines changed: 0 additions & 30 deletions
This file was deleted.

sign/appsettings.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

sign/filelist.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"publicReleaseRefSpec": [
55
"^refs/heads/release/\\d+\\.\\d+$"
66
],

0 commit comments

Comments
 (0)