Issues/86 v2 #196
Workflow file for this run
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
name: lf-repository-api-client-dotnet-CI | |
on: | |
push: | |
branches: [ '\d+.x' ] | |
pull_request: | |
branches: [ '\d+.x' ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
VERSION_PREFIX: '1.1.3' | |
GITHUB_PAGES_BRANCH: 'gh-pages' | |
jobs: | |
build-n-test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: | | |
3.1.x | |
6.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore | |
- name: Run unit tests | |
run: dotnet test tests/unit/Laserfiche.Repository.Api.Client.Test.csproj --no-build --verbosity normal --logger "trx;LogFileName=unit-test-results.trx" | |
- name: Run integration tests | |
env: | |
ACCESS_KEY: ${{ secrets.DEV_CA_PUBLIC_USE_INTEGRATION_TEST_ACCESS_KEY }} | |
SERVICE_PRINCIPAL_KEY: ${{ secrets.DEV_CA_PUBLIC_USE_TESTOAUTHSERVICEPRINCIPAL_SERVICE_PRINCIPAL_KEY }} | |
REPOSITORY_ID: ${{ secrets.DEV_CA_PUBLIC_USE_REPOSITORY_ID_1 }} | |
AUTHORIZATION_TYPE: ${{ secrets.AUTHORIZATION_TYPE }} | |
TEST_HEADER: ${{ secrets.TEST_HEADER }} | |
run: | |
dotnet test tests/integration/Laserfiche.Repository.Api.Client.IntegrationTest.csproj --no-build --verbosity normal --logger "trx;LogFileName=integration-test-results.trx" | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: Test Results | |
path: '**/*.trx' | |
reporter: dotnet-trx | |
only-summary: 'false' | |
list-tests: 'failed' | |
fail-on-error: 'false' | |
build-documentation: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: [ build-n-test ] # wait for build to finish | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
sudo apt-get install doxygen | |
sudo apt-get install graphviz | |
- name: Check dependency versions | |
run: | | |
doxygen --version | |
dot -V | |
- name: Create temporary directory | |
run: mkdir -p ./generated_documentation/ | |
- name: Rewrite doxygen config | |
run: | | |
sed -i 's|PROJECT_NUMBER = version|PROJECT_NUMBER = ${{ env.VERSION_PREFIX }}|i' ./doxygen/doxygen.conf | |
- name: Dump doxygen.conf to check rewrite | |
run: head -n 200 ./doxygen/doxygen.conf | |
- name: Generate doxygen docs | |
run: doxygen ./doxygen/doxygen.conf | |
- name: Upload a Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: documentation-artifact | |
path: ${{ github.workspace }}/generated_documentation/html | |
- name: Delete temporary directory | |
run: rm -r ./generated_documentation | |
publish-preview-package: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
environment: preview | |
if: ${{ github.run_attempt != 1 }} | |
needs: [ build-n-test, build-documentation ] # wait for build to finish | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: 6.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore --configuration release | |
- name: set PACKAGE_VERSION environment | |
run: echo "PACKAGE_VERSION=${{ env.VERSION_PREFIX }}-beta-${{ github.run_id }}" >> $GITHUB_ENV | |
- name: Packaging | |
run: dotnet pack --no-build --configuration release /p:version=${{ env.PACKAGE_VERSION }} | |
- name: Publish to Nuget.org | |
run: dotnet nuget push ./src/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json | |
- name: Tag commit | |
uses: rickstaa/action-create-tag@v1 | |
with: | |
tag: ${{ env.PACKAGE_VERSION }} | |
commit_sha: ${{ github.sha }} | |
message: Workflow run ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
publish-production-package: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
environment: production | |
if: ${{ github.run_attempt != 1 }} | |
needs: [ build-n-test, build-documentation ] # wait for build to finish | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: 6.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore --configuration release | |
- name: set PACKAGE_VERSION environment | |
run: echo "PACKAGE_VERSION=${{ env.VERSION_PREFIX }}" >> $GITHUB_ENV | |
- name: Packaging | |
run: dotnet pack --no-build --configuration release /p:version=${{ env.PACKAGE_VERSION }} | |
- name: Publish to Nuget.org | |
run: dotnet nuget push ./src/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json | |
- name: Tag commit | |
uses: rickstaa/action-create-tag@v1 | |
with: | |
tag: ${{ env.PACKAGE_VERSION }} | |
commit_sha: ${{ github.sha }} | |
message: Workflow run ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
publish-documentation: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
environment: github-pages | |
needs: [ publish-production-package ] | |
steps: | |
- name: Set DOCUMENTATION_VERSION environment variable | |
run: | | |
if [[ '${{ github.event_name }}' == 'pull_request' ]]; then | |
echo 'DOCUMENTATION_VERSION=${{ github.base_ref }}' >> $GITHUB_ENV | |
elif [[ '${{ github.ref_protected }}' == 'true' && '${{ github.ref_type }}' == 'branch' ]]; then | |
echo 'DOCUMENTATION_VERSION=${{ github.ref_name }}' >> $GITHUB_ENV | |
else | |
echo '::error::Unable to publish documentation for the current branch.' | |
exit 1 | |
fi | |
- name: Print DOCUMENTATION_VERSION environment variable | |
run: | | |
echo 'Publishing documentation to ${{ env.GITHUB_PAGES_BRANCH }} for ${{ env.DOCUMENTATION_VERSION }}.' | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ env.GITHUB_PAGES_BRANCH }} | |
- name: Delete documentation directory | |
run: rm -f -r ./docs/${{ env.DOCUMENTATION_VERSION }} | |
- name: Create documentation directory | |
run: mkdir -p ./docs/${{ env.DOCUMENTATION_VERSION }} | |
- name: Download documentation build artifact | |
uses: actions/[email protected] | |
with: | |
name: documentation-artifact | |
path: ./docs/${{ env.DOCUMENTATION_VERSION }} | |
- name: Create Pull Request | |
uses: peter-evans/[email protected] | |
with: | |
branch: ${{ env.GITHUB_PAGES_BRANCH }}-${{ env.DOCUMENTATION_VERSION }}-patch | |
delete-branch: true | |
title: "Automated documentation update for ${{ env.DOCUMENTATION_VERSION }} by action ${{ github.run_id }}" | |
commit-message: "Automated documentation update for ${{ env.DOCUMENTATION_VERSION }} by action ${{ github.run_id }}" | |
body: "Automated documentation update for ${{ env.DOCUMENTATION_VERSION }} by action ${{ github.run_id }}" | |
assignees: ${{ github.actor }} |