-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflows for build and release (#2)
- Loading branch information
Showing
6 changed files
with
169 additions
and
17 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
The workflows in this repository try to follow existing, basic samples with little customization. | ||
|
||
## main.yml | ||
We use a standard dotnet build/test/pack workflow | ||
https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | ||
|
||
- Build the solution using the dotnet cli | ||
- Strong name the assemblies using a key stored in the repository | ||
https://github.com/dotnet/runtime/blob/main/docs/project/strong-name-signing.md | ||
- Test the built libraries | ||
- In a PR run, only local tests are run. | ||
- In a CI run, live tests are run using a repository secret containing an OpenAI token | ||
https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions | ||
- Package the built libraries | ||
- Publish the package to a GitHub NuGet registry | ||
https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry | ||
- Publish a single build artifact containing test results and a nuget package | ||
|
||
## release.yml | ||
Releases are triggered by publishing a release in the GitHub repository. The release workflow will: | ||
|
||
- Build the solution using the dotnet cli | ||
- Strong name the assemblies using a key stored in the repository | ||
- Test the built libraries | ||
- Live tests are run using a repository secret containing an OpenAI token | ||
- Package the built libraries | ||
- Publish the package to public NuGet registry | ||
- Publish a single build artifact containing test results and a nuget package |
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,60 @@ | ||
name: Build and Test | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
build: # Test, pack and publish the Open AI nuget package as a build artifact | ||
runs-on: ubuntu-latest | ||
env: | ||
version_suffix_args: ${{ format('--version-suffix="alpha.{0}"', github.run_number) }} | ||
steps: | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 8.x | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build and Pack | ||
run: dotnet pack | ||
--configuration Release | ||
--output "${{github.workspace}}/artifacts/packages" | ||
${{ env.version_suffix_args }} | ||
|
||
- name: Test | ||
run: dotnet test | ||
--configuration Release | ||
--filter="TestCategory~${{ github.event_name == 'pull_request' && 'Offline' || 'Online' }}" | ||
--logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/full.trx" | ||
env: | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: build-artifacts | ||
path: ${{github.workspace}}/artifacts | ||
|
||
- name: NuGet Autenticate | ||
if: github.event_name != 'pull_request' | ||
run: dotnet nuget add source | ||
"https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | ||
--name "github" | ||
--username ${{ github.actor }} | ||
--password ${{ secrets.GITHUB_TOKEN }} | ||
--store-password-in-clear-text | ||
|
||
- name: Publish | ||
if: github.event_name != 'pull_request' | ||
run: dotnet nuget push | ||
${{github.workspace}}/artifacts/packages/*.nupkg | ||
--source "github" | ||
--api-key ${{ secrets.GITHUB_TOKEN }} | ||
--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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Release package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '8.x' # SDK Version to use. | ||
|
||
# Pack the client nuget package and include urls back to the repository and release tag | ||
- name: Build and Pack | ||
run: dotnet pack | ||
--configuration Release | ||
--output "${{github.workspace}}/artifacts/packages" | ||
/p:RepositoryUrl="${{ github.repository }}" | ||
/p:PackageProjectUrl="${{ github.repository }}/tree/${{ github.event.release.tag_name }}" | ||
|
||
- name: Test | ||
run: dotnet test | ||
--configuration Release | ||
--filter="TestCategory~Online" | ||
--logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/full.trx" | ||
env: | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
|
||
# Append the nuget package to the github release that triggered this workflow | ||
- name: Upload release asset | ||
run: gh release upload ${{ github.event.release.tag_name }} | ||
${{github.workspace}}/artifacts/packages/*.nupkg | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: build-artifacts | ||
path: ${{github.workspace}}/artifacts | ||
|
||
# - name: Publish | ||
# run: dotnet nuget push | ||
# ${{github.workspace}}/artifacts/packages/*.nupkg | ||
# --source https://api.nuget.org/v3/index.json | ||
# --api-key ${{ secrets.NUGET_API_KEY }} | ||
# --skip-duplicate |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.