|
1 | | -name: Maui CI |
| 1 | +name: WalletFramework CI |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - main |
7 | | - pull_request: |
8 | | - branches: |
9 | | - - main |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - develop |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - develop |
| 13 | + - 'release/**' |
10 | 14 |
|
11 | 15 | env: |
12 | | - BUILD_CONFIG: 'Release' |
13 | | - SOLUTION: 'src/WalletFramework.sln' |
14 | | - IS_PULL_REQUEST: ${{ github.event_name == 'pull_request' }} |
15 | | - IS_MAIN_BRANCH: ${{ github.ref == 'refs/heads/main' }} |
| 16 | + BUILD_CONFIG: 'Release' |
| 17 | + SOLUTION: 'src/WalletFramework.sln' |
| 18 | + IS_PULL_REQUEST: ${{ github.event_name == 'pull_request' }} |
| 19 | + IS_DEVELOP_BRANCH: ${{ github.ref == 'refs/heads/develop' }} |
| 20 | + IS_RELEASE_BRANCH: ${{ startsWith(github.ref, 'refs/heads/release/') }} |
| 21 | + IS_MAIN_BRANCH: ${{ github.ref == 'refs/heads/main' }} |
16 | 22 |
|
17 | | -jobs: |
18 | | - build: |
19 | | - |
20 | | - runs-on: ubuntu-22.04 |
21 | | - |
22 | | - steps: |
23 | | - - uses: actions/checkout@v2 |
24 | | - with: |
25 | | - fetch-depth: 0 |
26 | | - |
27 | | - - name: Set Version |
28 | | - run: | |
29 | | - sudo apt-get update && sudo apt-get install -y libxml2-utils |
30 | | - VERSION=$(xmllint --xpath "string(/Project/PropertyGroup/Version)" Directory.Build.props) |
31 | | - if $IS_MAIN_BRANCH; then |
32 | | - COMMIT_COUNT=$(git log --oneline | wc -l) |
33 | | - SUFFIX="-rc.$COMMIT_COUNT" |
34 | | - elif $IS_PULL_REQUEST; then |
35 | | - COMMIT_COUNT=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits?per_page=100" | jq length) |
36 | | - SUFFIX="-pr.${{ github.event.pull_request.number }}.$COMMIT_COUNT" |
37 | | - fi |
38 | | - echo "APP_VERSION=$VERSION$SUFFIX" >> $GITHUB_ENV |
| 23 | +jobs: |
| 24 | + build: |
| 25 | + runs-on: ubuntu-22.04 |
39 | 26 |
|
40 | | - - name: Setup .NET |
41 | | - uses: actions/setup-dotnet@v3 |
42 | | - with: |
43 | | - global-json-file: global.json |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v2 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
44 | 31 |
|
45 | | -# - name: Install libindy library |
46 | | -# run: | |
47 | | -# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88 |
48 | | -# sudo add-apt-repository "deb https://repo.sovrin.org/sdk/deb bionic stable" |
49 | | -# sudo apt-get update \ |
50 | | -# apt-get install -y libindy |
51 | | - |
52 | | - - name: Restore dependencies |
53 | | - run: dotnet restore $SOLUTION |
54 | | - |
55 | | - - name: Build |
56 | | - run: dotnet build $SOLUTION --configuration $BUILD_CONFIG -p:Version=$APP_VERSION |
| 32 | + - name: Set Version |
| 33 | + env: |
| 34 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + run: | |
| 36 | + sudo apt-get update && sudo apt-get install -y libxml2-utils jq |
| 37 | + VERSION=$(xmllint --xpath "string(/Project/PropertyGroup/Version)" Directory.Build.props) |
| 38 | + SUFFIX="" |
| 39 | + if $IS_MAIN_BRANCH; then |
| 40 | + SUFFIX="" |
| 41 | + elif $IS_RELEASE_BRANCH; then |
| 42 | + WORKFLOW_ID=$(gh workflow list --json name,id -q ".[] | select(.name == \"${{ github.workflow }}\") | .id") |
| 43 | + echo "workflowID is $WORKFLOW_ID" |
| 44 | + RUN_COUNT=$(gh run list --workflow "$WORKFLOW_ID" --branch "${{ github.ref_name }}" --json status -q "[.[] | select(.status != \"in_progress\" and .status != \"queued\")] | length") |
| 45 | + echo "run count is $RUN_COUNT" |
| 46 | + RC_NUMBER=$((RUN_COUNT + 1)) |
| 47 | + echo "RC_NUMBER=$RC_NUMBER" >> $GITHUB_OUTPUT |
| 48 | + SUFFIX="-rc.$RC_NUMBER" |
| 49 | + elif $IS_DEVELOP_BRANCH; then |
| 50 | + PR_NUMBER=${{ github.event.pull_request.number }} |
| 51 | + SUFFIX="-dev.$PR_NUMBER" |
| 52 | + elif $IS_PULL_REQUEST; then |
| 53 | + PR_NUMBER=${{ github.event.pull_request.number }} |
| 54 | + COMMIT_COUNT=$(git rev-list --count HEAD) |
| 55 | + SUFFIX="-pr.$PR_NUMBER.$COMMIT_COUNT" |
| 56 | + fi |
| 57 | + echo "APP_VERSION=$VERSION$SUFFIX" >> $GITHUB_ENV |
57 | 58 |
|
58 | | - - name: Run tests |
59 | | - run: | |
60 | | - dotnet test test/WalletFramework.Core.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
61 | | - dotnet test test/WalletFramework.MdocLib.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
62 | | - dotnet test test/WalletFramework.MdocVc.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
63 | | - dotnet test test/WalletFramework.Oid4Vc.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
64 | | - dotnet test test/WalletFramework.SdJwtVc.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
65 | | - dotnet test test/WalletFramework.SdJwtLib.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
| 59 | + - name: Setup .NET |
| 60 | + uses: actions/setup-dotnet@v4 |
| 61 | + with: |
| 62 | + global-json-file: global.json |
66 | 63 |
|
67 | | - - name: Pack WalletFramework |
68 | | - run: dotnet pack $SOLUTION --configuration $BUILD_CONFIG -p:Version=$APP_VERSION --no-build --output . |
| 64 | + - name: Restore dependencies |
| 65 | + run: dotnet restore $SOLUTION |
69 | 66 |
|
70 | | - - name: Publish |
71 | | - run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} |
| 67 | + - name: Build |
| 68 | + run: dotnet build $SOLUTION --configuration $BUILD_CONFIG -p:Version=$APP_VERSION |
| 69 | + |
| 70 | + - name: Run tests |
| 71 | + run: | |
| 72 | + dotnet test test/WalletFramework.Core.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
| 73 | + dotnet test test/WalletFramework.MdocLib.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
| 74 | + dotnet test test/WalletFramework.MdocVc.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
| 75 | + dotnet test test/WalletFramework.Oid4Vc.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
| 76 | + dotnet test test/WalletFramework.SdJwtVc.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
| 77 | + dotnet test test/WalletFramework.SdJwtLib.Tests --configuration $BUILD_CONFIG --no-restore --no-build |
| 78 | +
|
| 79 | + - name: Pack WalletFramework |
| 80 | + run: dotnet pack $SOLUTION --configuration $BUILD_CONFIG -p:Version=$APP_VERSION --no-build --output . |
| 81 | + |
| 82 | + - name: Publish to NuGet (main and release branches only) |
| 83 | + if: env.IS_PULL_REQUEST == 'false' && (env.IS_MAIN_BRANCH == 'true' || env.IS_RELEASE_BRANCH == 'true') |
| 84 | + run: | |
| 85 | + echo 'BUILD NUGET' |
| 86 | +# TODO: Add the nuget push after the pipeline functionality is fully tested. |
| 87 | +# run: dotnet nuget push "**/*.nupkg" --source 'https://api.nuget.org/v3/index.json' --api-key ${{ secrets.NUGET_API_KEY }} |
0 commit comments