-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b7ce7e
commit bb83972
Showing
14 changed files
with
342 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,17 @@ | |
SystemDescription identityServer = new("identity-server", "identity-server.slnf", "is"); | ||
GenerateIdentityServerWorkflow(identityServer); | ||
GenerateIdentityServerReleaseWorkflow(identityServer); | ||
|
||
GenerateTemplatesReleaseWorkflow(identityServer); | ||
|
||
} | ||
|
||
{ | ||
SystemDescription bff = new("bff", "bff.slnf", "bff"); | ||
GenerateBffWorkflow(bff); | ||
GenerateBffReleaseWorkflow(bff); | ||
|
||
GenerateTemplatesReleaseWorkflow(bff); | ||
} | ||
|
||
|
||
|
@@ -67,7 +72,9 @@ void GenerateIdentityServerWorkflow(SystemDescription system) | |
|
||
job.StepToolRestore(); | ||
|
||
job.StepPackSolution(system.Solution); | ||
job.StepPack(system.Solution); | ||
|
||
job.StepPack(system.TemplateProject); | ||
|
||
job.StepSign(); | ||
|
||
|
@@ -109,7 +116,7 @@ git config --global user.name ""Duende Software GitHub Bot"" | |
git tag -a {system.TagPrefix}-{contexts.Event.Input.Version} -m ""Release v{contexts.Event.Input.Version}"" | ||
git push origin {system.TagPrefix}-{contexts.Event.Input.Version}"); | ||
|
||
job.StepPackSolution(system.Solution); | ||
job.StepPack(system.Solution); | ||
|
||
job.StepToolRestore(); | ||
|
||
|
@@ -197,7 +204,7 @@ void GenerateBffWorkflow(SystemDescription system) | |
|
||
job.StepToolRestore(); | ||
|
||
job.StepPackSolution(system.Solution); | ||
job.StepPack(system.Solution); | ||
|
||
job.StepSign(); | ||
|
||
|
@@ -239,7 +246,8 @@ git config --global user.name ""Duende Software GitHub Bot"" | |
git tag -a {system.TagPrefix}-{contexts.Event.Input.Version} -m ""Release v{contexts.Event.Input.Version}"" | ||
git push origin {system.TagPrefix}-{contexts.Event.Input.Version}"); | ||
|
||
job.StepPackSolution(system.Solution); | ||
job.StepPack(system.Solution); | ||
job.StepPack(system.TemplateProject); | ||
|
||
job.StepToolRestore(); | ||
|
||
|
@@ -274,6 +282,69 @@ git tag -a {system.TagPrefix}-{contexts.Event.Input.Version} -m ""Release v{cont | |
WriteWorkflow(workflow, fileName); | ||
} | ||
|
||
void GenerateTemplatesReleaseWorkflow(SystemDescription system) | ||
{ | ||
var workflow = new Workflow($"{system.Name}/templates/release"); | ||
|
||
workflow.On | ||
.WorkflowDispatch() | ||
.Inputs(new StringInput("version", "Version in format X.Y.Z or X.Y.Z-preview.", true, "0.0.0")); | ||
|
||
workflow.EnvDefaults(); | ||
|
||
var job = workflow | ||
.Job("tag") | ||
.Name("Tag and Pack") | ||
.RunsOn(GitHubHostedRunners.UbuntuLatest) | ||
.Permissions(contents: Permission.Write, packages: Permission.Write) | ||
.Defaults().Run("bash", system.Name).Job; | ||
|
||
job.Step() | ||
.ActionsCheckout(); | ||
|
||
job.StepSetupDotNet(); | ||
|
||
job.Step() | ||
.Name("Git tag") | ||
.Run($@"git config --global user.email ""[email protected]"" | ||
git config --global user.name ""Duende Software GitHub Bot"" | ||
git tag -a templates-{system.TagPrefix}-{contexts.Event.Input.Version} -m ""Release v{contexts.Event.Input.Version}"" | ||
git push origin templates-{system.TagPrefix}-{contexts.Event.Input.Version}"); | ||
|
||
job.StepPack(system.TemplateProject); | ||
|
||
job.StepToolRestore(); | ||
|
||
job.StepSign(); | ||
|
||
job.StepPushToMyGet(); | ||
|
||
job.StepPushToGithub(contexts); | ||
|
||
job.StepUploadArtifacts(system.Name); | ||
|
||
var publishJob = workflow.Job("publish") | ||
.Name("Publish to nuget.org") | ||
.RunsOn(GitHubHostedRunners.UbuntuLatest) | ||
.Needs("tag") | ||
.Environment("nuget.org", ""); | ||
|
||
publishJob.Step() | ||
.Uses("actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16") // 4.1.8 | ||
.With(("name", "artifacts"), ("path", "artifacts")); | ||
|
||
publishJob.StepSetupDotNet(); | ||
|
||
publishJob.Step() | ||
.Name("List files") | ||
.Shell("bash") | ||
.Run("tree"); | ||
|
||
publishJob.StepPushToNuget(); | ||
|
||
var fileName = $"{system.Name}-templates-release"; | ||
WriteWorkflow(workflow, fileName); | ||
} | ||
|
||
void WriteWorkflow(Workflow workflow, string fileName) | ||
{ | ||
|
@@ -282,7 +353,10 @@ void WriteWorkflow(Workflow workflow, string fileName) | |
Console.WriteLine($"Wrote workflow to {filePath}"); | ||
} | ||
|
||
record SystemDescription(string Name, string Solution, string TagPrefix); | ||
record SystemDescription(string Name, string Solution, string TagPrefix) | ||
{ | ||
public string TemplateProject => $"{Name}/templates/templates.{Name}.csproj"; | ||
} | ||
|
||
public static class StepExtensions | ||
{ | ||
|
@@ -323,11 +397,11 @@ public static void StepToolRestore(this Job job) | |
.Name("Tool restore") | ||
.Run("dotnet tool restore"); | ||
|
||
public static void StepPackSolution(this Job job, string solution) | ||
public static void StepPack(this Job job, string target) | ||
{ | ||
job.Step() | ||
.Name($"Pack {solution}") | ||
.Run($"dotnet pack -c Release {solution} -o artifacts"); | ||
.Name($"Pack {target}") | ||
.Run($"dotnet pack -c Release {target} -o artifacts"); | ||
} | ||
|
||
public static Step StepBuild(this Job job, string solution) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# This was generated by tool. Edits will be overwritten. | ||
|
||
name: bff/templates/release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version in format X.Y.Z or X.Y.Z-preview.' | ||
type: string | ||
required: true | ||
default: '0.0.0' | ||
env: | ||
DOTNET_NOLOGO: true | ||
DOTNET_CLI_TELEMETRY_OPTOUT: true | ||
jobs: | ||
tag: | ||
name: Tag and Pack | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
packages: write | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: bff | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Dotnet | ||
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 | ||
with: | ||
dotnet-version: |- | ||
6.0.x | ||
8.0.x | ||
9.0.x | ||
- name: Git tag | ||
run: |- | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Duende Software GitHub Bot" | ||
git tag -a templates-bff-${{ github.event.inputs.version }} -m "Release v${{ github.event.inputs.version }}" | ||
git push origin templates-bff-${{ github.event.inputs.version }} | ||
- name: Pack bff/templates/templates.bff.csproj | ||
run: dotnet pack -c Release bff/templates/templates.bff.csproj -o artifacts | ||
- name: Tool restore | ||
run: dotnet tool restore | ||
- name: Sign packages | ||
if: github.event == 'push' | ||
run: |- | ||
for file in artifacts/*.nupkg; do | ||
dotnet NuGetKeyVaultSignTool sign "$file" --file-digest sha256 --timestamp-rfc3161 http://timestamp.digicert.com --azure-key-vault-url https://duendecodesigninghsm.vault.azure.net/ --azure-key-vault-client-id 18e3de68-2556-4345-8076-a46fad79e474 --azure-key-vault-tenant-id ed3089f0-5401-4758-90eb-066124e2d907 --azure-key-vault-client-secret ${{ secrets.SignClientSecret }} --azure-key-vault-certificate NuGetPackageSigning | ||
done | ||
- name: Push packages to MyGet | ||
if: github.ref == 'refs/heads/main' | ||
run: dotnet nuget push artifacts/*.nupkg --source https://www.myget.org/F/duende_identityserver/api/v2/package --api-key ${{ secrets.MYGET }} --skip-duplicate | ||
- name: Push packages to GitHub | ||
if: github.ref == 'refs/heads/main' | ||
run: dotnet nuget push artifacts/*.nupkg --source https://nuget.pkg.github.com/DuendeSoftware/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Upload Artifacts | ||
if: github.ref == 'refs/heads/main' | ||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 | ||
with: | ||
name: artifacts | ||
path: bff/artifacts/*.nupkg | ||
overwrite: true | ||
retention-days: 15 | ||
publish: | ||
name: Publish to nuget.org | ||
needs: | ||
- tag | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: nuget.org | ||
steps: | ||
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 | ||
with: | ||
name: artifacts | ||
path: artifacts | ||
- name: Setup Dotnet | ||
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 | ||
with: | ||
dotnet-version: |- | ||
6.0.x | ||
8.0.x | ||
9.0.x | ||
- name: List files | ||
run: tree | ||
shell: bash | ||
- name: Push packages to nuget.org | ||
if: github.ref == 'refs/heads/main' | ||
run: dotnet nuget push artifacts/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_ORG_API_KEY }} --skip-duplicate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# This was generated by tool. Edits will be overwritten. | ||
|
||
name: identity-server/templates/release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version in format X.Y.Z or X.Y.Z-preview.' | ||
type: string | ||
required: true | ||
default: '0.0.0' | ||
env: | ||
DOTNET_NOLOGO: true | ||
DOTNET_CLI_TELEMETRY_OPTOUT: true | ||
jobs: | ||
tag: | ||
name: Tag and Pack | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
packages: write | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: identity-server | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Dotnet | ||
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 | ||
with: | ||
dotnet-version: |- | ||
6.0.x | ||
8.0.x | ||
9.0.x | ||
- name: Git tag | ||
run: |- | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Duende Software GitHub Bot" | ||
git tag -a templates-is-${{ github.event.inputs.version }} -m "Release v${{ github.event.inputs.version }}" | ||
git push origin templates-is-${{ github.event.inputs.version }} | ||
- name: Pack identity-server/templates/templates.identity-server.csproj | ||
run: dotnet pack -c Release identity-server/templates/templates.identity-server.csproj -o artifacts | ||
- name: Tool restore | ||
run: dotnet tool restore | ||
- name: Sign packages | ||
if: github.event == 'push' | ||
run: |- | ||
for file in artifacts/*.nupkg; do | ||
dotnet NuGetKeyVaultSignTool sign "$file" --file-digest sha256 --timestamp-rfc3161 http://timestamp.digicert.com --azure-key-vault-url https://duendecodesigninghsm.vault.azure.net/ --azure-key-vault-client-id 18e3de68-2556-4345-8076-a46fad79e474 --azure-key-vault-tenant-id ed3089f0-5401-4758-90eb-066124e2d907 --azure-key-vault-client-secret ${{ secrets.SignClientSecret }} --azure-key-vault-certificate NuGetPackageSigning | ||
done | ||
- name: Push packages to MyGet | ||
if: github.ref == 'refs/heads/main' | ||
run: dotnet nuget push artifacts/*.nupkg --source https://www.myget.org/F/duende_identityserver/api/v2/package --api-key ${{ secrets.MYGET }} --skip-duplicate | ||
- name: Push packages to GitHub | ||
if: github.ref == 'refs/heads/main' | ||
run: dotnet nuget push artifacts/*.nupkg --source https://nuget.pkg.github.com/DuendeSoftware/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Upload Artifacts | ||
if: github.ref == 'refs/heads/main' | ||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 | ||
with: | ||
name: artifacts | ||
path: identity-server/artifacts/*.nupkg | ||
overwrite: true | ||
retention-days: 15 | ||
publish: | ||
name: Publish to nuget.org | ||
needs: | ||
- tag | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: nuget.org | ||
steps: | ||
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 | ||
with: | ||
name: artifacts | ||
path: artifacts | ||
- name: Setup Dotnet | ||
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 | ||
with: | ||
dotnet-version: |- | ||
6.0.x | ||
8.0.x | ||
9.0.x | ||
- name: List files | ||
run: tree | ||
shell: bash | ||
- name: Push packages to nuget.org | ||
if: github.ref == 'refs/heads/main' | ||
run: dotnet nuget push artifacts/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_ORG_API_KEY }} --skip-duplicate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.