diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7e90f63d..91e5c470 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -76,6 +76,9 @@ "installDockerComposeSwitch": true, "moby": true, "version": "latest" + }, + "ghcr.io/devcontainers/features/dotnet:2.4.0": { + "version": "8.0" } }, "mounts": [ diff --git a/.github/actions/build-sdk/action.yml b/.github/actions/build-sdk/action.yml index 0443d76c..22d46521 100644 --- a/.github/actions/build-sdk/action.yml +++ b/.github/actions/build-sdk/action.yml @@ -49,7 +49,6 @@ runs: run: | make build VERSION="${{ inputs.version }}" - - name: Upload API OAS specification artifact uses: actions/upload-artifact@v4 with: @@ -86,13 +85,6 @@ runs: path: "sdk/csharp" name: sdk-csharp-${{ inputs.version }} - # - name: Upload artifact - # # Automatically uploads an artifact from the './_site' directory by default - # uses: actions/upload-pages-artifact@v3 - # with: - # path: "docs/_site/" - # name: jekyll-docs-${{ inputs.version }} - - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: diff --git a/.github/workflows/stage-3-build.yaml b/.github/workflows/stage-3-build.yaml index 21d38c70..73d74f4c 100644 --- a/.github/workflows/stage-3-build.yaml +++ b/.github/workflows/stage-3-build.yaml @@ -38,7 +38,7 @@ on: permissions: id-token: write # This is required for requesting the JWT - contents: read # This is required for actions/checkout + contents: read # This is required for actions/checkout jobs: artefact-jekyll-docs: name: "Build Docs" @@ -64,29 +64,29 @@ jobs: with: version: "${{ inputs.version }}" - artefact-servers: - name: "Build servers" - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: "Checkout code" - uses: actions/checkout@v5 - - name: "Build servers" - uses: ./.github/actions/build-server - with: - version: "${{ inputs.version }}" - - artefact-libs: - name: "Build libs" - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: "Checkout code" - uses: actions/checkout@v5 - - name: "Build servers" - uses: ./.github/actions/build-libraries - with: - version: "${{ inputs.version }}" + # Take out for now - might add again in the future + # artefact-servers: + # name: "Build servers" + # runs-on: ubuntu-latest + # timeout-minutes: 10 + # steps: + # - name: "Checkout code" + # uses: actions/checkout@v5 + # - name: "Build servers" + # uses: ./.github/actions/build-server + # with: + # version: "${{ inputs.version }}" + # artefact-libs: + # name: "Build libs" + # runs-on: ubuntu-latest + # timeout-minutes: 10 + # steps: + # - name: "Checkout code" + # uses: actions/checkout@v5 + # - name: "Build servers" + # uses: ./.github/actions/build-libraries + # with: + # version: "${{ inputs.version }}" artefact-proxies: name: "Build proxies" @@ -109,38 +109,3 @@ jobs: runId: "${{ github.run_id }}" buildSandbox: true releaseVersion: ${{ github.head_ref || github.ref_name }} - - # artefact-1: - # name: "Artefact 1" - # runs-on: ubuntu-latest - # timeout-minutes: 3 - # steps: - # - name: "Checkout code" - # uses: actions/checkout@v5 - # - name: "Build artefact 1" - # run: | - # echo "Building artefact 1 ..." - # - name: "Check artefact 1" - # run: | - # echo "Checking artefact 1 ..." - # - name: "Upload artefact 1" - # run: | - # echo "Uploading artefact 1 ..." - # # Use either action/cache or action/upload-artifact - # artefact-n: - # name: "Artefact n" - # runs-on: ubuntu-latest - # timeout-minutes: 3 - # steps: - # - name: "Checkout code" - # uses: actions/checkout@v5 - # - name: "Build artefact n" - # run: | - # echo "Building artefact n ..." - # - name: "Check artefact n" - # run: | - # echo "Checking artefact n ..." - # - name: "Upload artefact n" - # run: | - # echo "Uploading artefact n ..." - # # Use either action/cache or action/upload-artifact diff --git a/.github/workflows/stage-5-publish.yaml b/.github/workflows/stage-5-publish.yaml index c23c08b8..1c7eb36f 100644 --- a/.github/workflows/stage-5-publish.yaml +++ b/.github/workflows/stage-5-publish.yaml @@ -93,11 +93,12 @@ jobs: path: ./artifacts/api-oas-specification-${{ inputs.version }} name: api-oas-specification-${{ inputs.version }} - - name: "Get the artefacts 9" - uses: actions/download-artifact@v5 - with: - path: ./artifacts/server-csharp-${{ inputs.version }} - name: server-csharp-${{ inputs.version }} + # Take out for now - might add again in the future + # - name: "Get the artefacts 9" + # uses: actions/download-artifact@v5 + # with: + # path: ./artifacts/server-csharp-${{ inputs.version }} + # name: server-csharp-${{ inputs.version }} - name: "Create release" id: create_release @@ -112,8 +113,7 @@ jobs: draft: false prerelease: ${{ inputs.is_version_prerelease == 'true'}} - - - name: "Upload jeykll docs release asset" + - name: "Upload jekyll docs release asset" uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -143,7 +143,6 @@ jobs: asset_name: sdk-swagger-docs-${{ inputs.version }}.tar asset_content_type: "application/gzip" - - name: "zip html release asset" # Git hub pages needs a single tar called artifact inside the zip. working-directory: ./artifacts/sdk-html-${{ inputs.version }} @@ -192,9 +191,6 @@ jobs: asset_name: sdk-python-${{ inputs.version }}.zip asset_content_type: "application/gzip" - - - - name: "zip sdk csharp release asset" # Git hub pages needs a single tar called artifact inside the zip. working-directory: ./artifacts/sdk-csharp-${{ inputs.version }} @@ -227,53 +223,53 @@ jobs: asset_name: api-oas-specification-${{ inputs.version }}.zip asset_content_type: "application/gzip" + # Take out for now - might add again in the future + # - name: "zip csharp server release asset" + # # Git hub pages needs a single tar called artifact inside the zip. + # working-directory: ./artifacts/server-csharp-${{ inputs.version }} + # run: zip -r ../server-csharp-${{ inputs.version }}.zip . + # shell: bash - - name: "zip csharp server release asset" - # Git hub pages needs a single tar called artifact inside the zip. - working-directory: ./artifacts/server-csharp-${{ inputs.version }} - run: zip -r ../server-csharp-${{ inputs.version }}.zip . - shell: bash - - - name: "Upload csharp server release asset" - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: "${{ steps.create_release.outputs.upload_url }}" - asset_path: ./artifacts/server-csharp-${{ inputs.version }}.zip - asset_name: server-csharp-${{ inputs.version }}.zip - asset_content_type: "application/gzip" - - -### PUBLISH DOCKER - THIS NEEDS CHANGING TO DO THE DOCKER BUILD IN THE BUILD STAGE AND ARTIFACT IT. SEE publishlibhostdocker below how how and the buildlibs action. - publishdocker: - name: "Publish docker packages" - runs-on: ubuntu-latest - needs: [publish] - permissions: - packages: write - contents: read - steps: - - name: "Get the artefacts csharp docker" - uses: actions/download-artifact@v5 - with: - path: . - name: server-csharp-docker-${{ inputs.version }} - - name: "Get the artefacts csharp server" - uses: actions/download-artifact@v5 - with: - path: ./csharp-server - name: server-csharp-${{ inputs.version }} - - run: ls -la - - run: | - docker build . -t ghcr.io/nhsdigital/nhsnotifysupplierserver:latest - echo $CR_PAT | docker login ghcr.io -u nhs-notify-supplier-api --password-stdin - docker push ghcr.io/nhsdigital/nhsnotifysupplierserver:latest - env: - CR_PAT: ${{ secrets.GITHUB_TOKEN }} - + # Take out for now - might add again in the future + # - name: "Upload csharp server release asset" + # uses: actions/upload-release-asset@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # upload_url: "${{ steps.create_release.outputs.upload_url }}" + # asset_path: ./artifacts/server-csharp-${{ inputs.version }}.zip + # asset_name: server-csharp-${{ inputs.version }}.zip + # asset_content_type: "application/gzip" -### PUBLISH NUGET + # Take out for now - might add again in the future + # ### PUBLISH DOCKER - THIS NEEDS CHANGING TO DO THE DOCKER BUILD IN THE BUILD STAGE AND ARTIFACT IT. SEE publishlibhostdocker below how how and the buildlibs action. + # publishdocker: + # name: "Publish docker packages" + # runs-on: ubuntu-latest + # needs: [publish] + # permissions: + # packages: write + # contents: read + # steps: + # - name: "Get the artefacts csharp docker" + # uses: actions/download-artifact@v5 + # with: + # path: . + # name: server-csharp-docker-${{ inputs.version }} + # - name: "Get the artefacts csharp server" + # uses: actions/download-artifact@v5 + # with: + # path: ./csharp-server + # name: server-csharp-${{ inputs.version }} + # - run: ls -la + # - run: | + # docker build . -t ghcr.io/nhsdigital/nhsnotifysupplierserver:latest + # echo $CR_PAT | docker login ghcr.io -u nhs-notify-supplier-api --password-stdin + # docker push ghcr.io/nhsdigital/nhsnotifysupplierserver:latest + # env: + # CR_PAT: ${{ secrets.GITHUB_TOKEN }} + + ### PUBLISH NUGET publishnuget: name: "Publish nuget packages to nuget.pkg.github.com" runs-on: ubuntu-latest @@ -328,7 +324,7 @@ jobs: TEST_NUGET_VERSION: ${{ steps.set-nuget-version.outputs.TEST_NUGET_VERSION }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -### Publish NPM + ### Publish NPM publishnpm: name: "Publish npm packages to npm.pkg.github.com" @@ -345,9 +341,9 @@ jobs: name: sdk-ts-${{ inputs.version }} - uses: actions/setup-node@v6 with: - node-version: '24.3' - registry-url: 'https://npm.pkg.github.com' - scope: '@NHSDigital' + node-version: "24.3" + registry-url: "https://npm.pkg.github.com" + scope: "@NHSDigital" - run: ls -la - run: npm cache clear --force @@ -358,31 +354,10 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - - # - name: "Upload other release asset 1" - # uses: actions/upload-release-asset@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # upload_url: "${{ steps.create_release.outputs.upload_url }}" - # asset_path: ./* - # asset_name: repository-template-${{ inputs.version }}.tar.gz - # asset_content_type: "application/gzip" - # - name: "Upload other release asset 2" - # uses: actions/upload-release-asset@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # upload_url: "${{ steps.create_release.outputs.upload_url }}" - # asset_path: ./* - # asset_name: repository-template-${{ inputs.version }}.tar.gz - # asset_content_type: "application/gzip" success: name: "Success notification" runs-on: ubuntu-latest - needs: [publish,publishnpm] + needs: [publish, publishnpm] steps: - name: "Check prerequisites for notification" id: check @@ -397,258 +372,251 @@ jobs: message-text: "This is a notification body" link: ${{ github.event.pull_request.html_url }} - -### PUBLISH LIBS ABSTRACTION NUGET - publishlibsabstractionsnuget: - name: "Publish libs abstractions packages to nuget.pkg.github.com" - runs-on: ubuntu-latest - needs: [publish] - permissions: - packages: write - contents: read - steps: - - name: "Get the artefacts" - uses: actions/download-artifact@v5 - with: - path: . - name: libs-abstractions-${{ inputs.version }} - - run: | - ls -la - find . -name ".version" - - run: | - dotnet nuget add source \ - --username nhs-notify-supplier-api \ - --password ${{ secrets.GITHUB_TOKEN }} \ - --store-password-in-clear-text \ - --name github \ - "https://nuget.pkg.github.com/NHSDigital/index.json" - - run: | - echo "ROOT .version file is: $(cat .version)" - echo "GH variable version is: ${{ inputs.version }}" - name: Showing the base versions - - - run: | - VERSION=${{ inputs.version }} - SHORT_VERSION="$(echo $VERSION | rev | cut -d"." -f2- | rev)" - NUGET_VERSION="$(echo "$VERSION" | tr + .)" - echo $VERSION - echo $SHORT_VERSION - echo $NUGET_VERSION - SHORT_NUGET_VERSION="$(echo $NUGET_VERSION | rev | cut -d"." -f2- | rev)" - echo $SHORT_NUGET_VERSION - SHORTER_NUGET_VERSION="$(echo $SHORT_NUGET_VERSION | rev | cut -d"." -f2- | rev)" - echo $SHORTER_NUGET_VERSION - TEST_NUGET_VERSION="$(echo $NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" - TEST_NUGET_VERSION="$(echo $TEST_NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" - echo $TEST_NUGET_VERSION - echo "TEST_NUGET_VERSION=$TEST_NUGET_VERSION" >> "$GITHUB_OUTPUT" - name: Set the nuget version - id: set-nuget-version - - - run: | - dotnet nuget push \ - nhs.notify.suppliers.api.abstractions.${TEST_NUGET_VERSION}.nupkg \ - --source github \ - --api-key $GITHUB_TOKEN - env: - TEST_NUGET_VERSION: ${{ steps.set-nuget-version.outputs.TEST_NUGET_VERSION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - -### PUBLISH LIBS LETTERS NUGET - publishliblettersnuget: - name: "Publish libs letter packages to nuget.pkg.github.com" - runs-on: ubuntu-latest - needs: [publish] - permissions: - packages: write - contents: read - steps: - - name: "Get the artefacts" - uses: actions/download-artifact@v5 - with: - path: . - name: libs-letter-${{ inputs.version }} - - run: | - ls -la - find . -name ".version" - - run: | - dotnet nuget add source \ - --username nhs-notify-supplier-api \ - --password ${{ secrets.GITHUB_TOKEN }} \ - --store-password-in-clear-text \ - --name github \ - "https://nuget.pkg.github.com/NHSDigital/index.json" - - run: | - echo "ROOT .version file is: $(cat .version)" - echo "GH variable version is: ${{ inputs.version }}" - name: Showing the base versions - - - run: | - VERSION=${{ inputs.version }} - SHORT_VERSION="$(echo $VERSION | rev | cut -d"." -f2- | rev)" - NUGET_VERSION="$(echo "$VERSION" | tr + .)" - echo $VERSION - echo $SHORT_VERSION - echo $NUGET_VERSION - SHORT_NUGET_VERSION="$(echo $NUGET_VERSION | rev | cut -d"." -f2- | rev)" - echo $SHORT_NUGET_VERSION - SHORTER_NUGET_VERSION="$(echo $SHORT_NUGET_VERSION | rev | cut -d"." -f2- | rev)" - echo $SHORTER_NUGET_VERSION - TEST_NUGET_VERSION="$(echo $NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" - TEST_NUGET_VERSION="$(echo $TEST_NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" - echo $TEST_NUGET_VERSION - echo "TEST_NUGET_VERSION=$TEST_NUGET_VERSION" >> "$GITHUB_OUTPUT" - name: Set the nuget version - id: set-nuget-version - - - run: | - dotnet nuget push \ - nhs.notify.suppliers.api.letter.${TEST_NUGET_VERSION}.nupkg \ - --source github \ - --api-key $GITHUB_TOKEN - env: - TEST_NUGET_VERSION: ${{ steps.set-nuget-version.outputs.TEST_NUGET_VERSION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - -### PUBLISH LIBS data NUGET - publishlibhostnuget: - name: "Publish libs data packages to nuget.pkg.github.com" - runs-on: ubuntu-latest - needs: [publish] - permissions: - packages: write - contents: read - steps: - - name: "Get the artefacts" - uses: actions/download-artifact@v5 - with: - path: . - name: libs-data-${{ inputs.version }} - - run: | - ls -la - find . -name ".version" - - run: | - dotnet nuget add source \ - --username nhs-notify-supplier-api \ - --password ${{ secrets.GITHUB_TOKEN }} \ - --store-password-in-clear-text \ - --name github \ - "https://nuget.pkg.github.com/NHSDigital/index.json" - - run: | - echo "ROOT .version file is: $(cat .version)" - echo "GH variable version is: ${{ inputs.version }}" - name: Showing the base versions - - - run: | - VERSION=${{ inputs.version }} - SHORT_VERSION="$(echo $VERSION | rev | cut -d"." -f2- | rev)" - NUGET_VERSION="$(echo "$VERSION" | tr + .)" - echo $VERSION - echo $SHORT_VERSION - echo $NUGET_VERSION - SHORT_NUGET_VERSION="$(echo $NUGET_VERSION | rev | cut -d"." -f2- | rev)" - echo $SHORT_NUGET_VERSION - SHORTER_NUGET_VERSION="$(echo $SHORT_NUGET_VERSION | rev | cut -d"." -f2- | rev)" - echo $SHORTER_NUGET_VERSION - TEST_NUGET_VERSION="$(echo $NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" - TEST_NUGET_VERSION="$(echo $TEST_NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" - echo $TEST_NUGET_VERSION - echo "TEST_NUGET_VERSION=$TEST_NUGET_VERSION" >> "$GITHUB_OUTPUT" - name: Set the nuget version - id: set-nuget-version - - - run: | - dotnet nuget push \ - nhs.notify.suppliers.api.data.${TEST_NUGET_VERSION}.nupkg \ - --source github \ - --api-key $GITHUB_TOKEN - env: - TEST_NUGET_VERSION: ${{ steps.set-nuget-version.outputs.TEST_NUGET_VERSION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - -### PUBLISH LIBS host NUGET - publishlibdatanuget: - name: "Publish libs host packages to nuget.pkg.github.com" - runs-on: ubuntu-latest - needs: [publish] - permissions: - packages: write - contents: read - steps: - - name: "Get the artefacts" - uses: actions/download-artifact@v5 - with: - path: . - name: libs-host-${{ inputs.version }} - - run: | - ls -la - find . -name ".version" - - run: | - dotnet nuget add source \ - --username nhs-notify-supplier-api \ - --password ${{ secrets.GITHUB_TOKEN }} \ - --store-password-in-clear-text \ - --name github \ - "https://nuget.pkg.github.com/NHSDigital/index.json" - - run: | - echo "ROOT .version file is: $(cat .version)" - echo "GH variable version is: ${{ inputs.version }}" - name: Showing the base versions - - - run: | - VERSION=${{ inputs.version }} - SHORT_VERSION="$(echo $VERSION | rev | cut -d"." -f2- | rev)" - NUGET_VERSION="$(echo "$VERSION" | tr + .)" - echo $VERSION - echo $SHORT_VERSION - echo $NUGET_VERSION - SHORT_NUGET_VERSION="$(echo $NUGET_VERSION | rev | cut -d"." -f2- | rev)" - echo $SHORT_NUGET_VERSION - SHORTER_NUGET_VERSION="$(echo $SHORT_NUGET_VERSION | rev | cut -d"." -f2- | rev)" - echo $SHORTER_NUGET_VERSION - TEST_NUGET_VERSION="$(echo $NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" - TEST_NUGET_VERSION="$(echo $TEST_NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" - echo $TEST_NUGET_VERSION - echo "TEST_NUGET_VERSION=$TEST_NUGET_VERSION" >> "$GITHUB_OUTPUT" - name: Set the nuget version - id: set-nuget-version - - - run: | - dotnet nuget push \ - nhs.notify.suppliers.api.host.${TEST_NUGET_VERSION}.nupkg \ - --source github \ - --api-key $GITHUB_TOKEN - env: - TEST_NUGET_VERSION: ${{ steps.set-nuget-version.outputs.TEST_NUGET_VERSION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - -### PUBLISH LIBS host docker - publishlibhostdocker: - name: "Publish libs host docker" - runs-on: ubuntu-latest - needs: [publish] - permissions: - packages: write - contents: read - steps: - - name: "Get the artefacts" - uses: actions/download-artifact@v5 - with: - path: . - name: libs-host-docker-${{ inputs.version }} - - - run: | - ls -Rla - docker load --input myimage.tar - docker image ls -a - echo $CR_PAT | docker login ghcr.io -u nhs-notify-supplier-api --password-stdin - docker push ghcr.io/nhsdigital/libshostdocker:latest - env: - CR_PAT: ${{ secrets.GITHUB_TOKEN }} + # Take out for now - might add again in the future + # ### PUBLISH LIBS ABSTRACTION NUGET + # publishlibsabstractionsnuget: + # name: "Publish libs abstractions packages to nuget.pkg.github.com" + # runs-on: ubuntu-latest + # needs: [publish] + # permissions: + # packages: write + # contents: read + # steps: + # - name: "Get the artefacts" + # uses: actions/download-artifact@v5 + # with: + # path: . + # name: libs-abstractions-${{ inputs.version }} + # - run: | + # ls -la + # find . -name ".version" + # - run: | + # dotnet nuget add source \ + # --username nhs-notify-supplier-api \ + # --password ${{ secrets.GITHUB_TOKEN }} \ + # --store-password-in-clear-text \ + # --name github \ + # "https://nuget.pkg.github.com/NHSDigital/index.json" + # - run: | + # echo "ROOT .version file is: $(cat .version)" + # echo "GH variable version is: ${{ inputs.version }}" + # name: Showing the base versions + + # - run: | + # VERSION=${{ inputs.version }} + # SHORT_VERSION="$(echo $VERSION | rev | cut -d"." -f2- | rev)" + # NUGET_VERSION="$(echo "$VERSION" | tr + .)" + # echo $VERSION + # echo $SHORT_VERSION + # echo $NUGET_VERSION + # SHORT_NUGET_VERSION="$(echo $NUGET_VERSION | rev | cut -d"." -f2- | rev)" + # echo $SHORT_NUGET_VERSION + # SHORTER_NUGET_VERSION="$(echo $SHORT_NUGET_VERSION | rev | cut -d"." -f2- | rev)" + # echo $SHORTER_NUGET_VERSION + # TEST_NUGET_VERSION="$(echo $NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" + # TEST_NUGET_VERSION="$(echo $TEST_NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" + # echo $TEST_NUGET_VERSION + # echo "TEST_NUGET_VERSION=$TEST_NUGET_VERSION" >> "$GITHUB_OUTPUT" + # name: Set the nuget version + # id: set-nuget-version + + # - run: | + # dotnet nuget push \ + # nhs.notify.suppliers.api.abstractions.${TEST_NUGET_VERSION}.nupkg \ + # --source github \ + # --api-key $GITHUB_TOKEN + # env: + # TEST_NUGET_VERSION: ${{ steps.set-nuget-version.outputs.TEST_NUGET_VERSION }} + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # ### PUBLISH LIBS LETTERS NUGET + # publishliblettersnuget: + # name: "Publish libs letter packages to nuget.pkg.github.com" + # runs-on: ubuntu-latest + # needs: [publish] + # permissions: + # packages: write + # contents: read + # steps: + # - name: "Get the artefacts" + # uses: actions/download-artifact@v5 + # with: + # path: . + # name: libs-letter-${{ inputs.version }} + # - run: | + # ls -la + # find . -name ".version" + # - run: | + # dotnet nuget add source \ + # --username nhs-notify-supplier-api \ + # --password ${{ secrets.GITHUB_TOKEN }} \ + # --store-password-in-clear-text \ + # --name github \ + # "https://nuget.pkg.github.com/NHSDigital/index.json" + # - run: | + # echo "ROOT .version file is: $(cat .version)" + # echo "GH variable version is: ${{ inputs.version }}" + # name: Showing the base versions + + # - run: | + # VERSION=${{ inputs.version }} + # SHORT_VERSION="$(echo $VERSION | rev | cut -d"." -f2- | rev)" + # NUGET_VERSION="$(echo "$VERSION" | tr + .)" + # echo $VERSION + # echo $SHORT_VERSION + # echo $NUGET_VERSION + # SHORT_NUGET_VERSION="$(echo $NUGET_VERSION | rev | cut -d"." -f2- | rev)" + # echo $SHORT_NUGET_VERSION + # SHORTER_NUGET_VERSION="$(echo $SHORT_NUGET_VERSION | rev | cut -d"." -f2- | rev)" + # echo $SHORTER_NUGET_VERSION + # TEST_NUGET_VERSION="$(echo $NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" + # TEST_NUGET_VERSION="$(echo $TEST_NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" + # echo $TEST_NUGET_VERSION + # echo "TEST_NUGET_VERSION=$TEST_NUGET_VERSION" >> "$GITHUB_OUTPUT" + # name: Set the nuget version + # id: set-nuget-version + + # - run: | + # dotnet nuget push \ + # nhs.notify.suppliers.api.letter.${TEST_NUGET_VERSION}.nupkg \ + # --source github \ + # --api-key $GITHUB_TOKEN + # env: + # TEST_NUGET_VERSION: ${{ steps.set-nuget-version.outputs.TEST_NUGET_VERSION }} + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # ### PUBLISH LIBS data NUGET + # publishlibhostnuget: + # name: "Publish libs data packages to nuget.pkg.github.com" + # runs-on: ubuntu-latest + # needs: [publish] + # permissions: + # packages: write + # contents: read + # steps: + # - name: "Get the artefacts" + # uses: actions/download-artifact@v5 + # with: + # path: . + # name: libs-data-${{ inputs.version }} + # - run: | + # ls -la + # find . -name ".version" + # - run: | + # dotnet nuget add source \ + # --username nhs-notify-supplier-api \ + # --password ${{ secrets.GITHUB_TOKEN }} \ + # --store-password-in-clear-text \ + # --name github \ + # "https://nuget.pkg.github.com/NHSDigital/index.json" + # - run: | + # echo "ROOT .version file is: $(cat .version)" + # echo "GH variable version is: ${{ inputs.version }}" + # name: Showing the base versions + + # - run: | + # VERSION=${{ inputs.version }} + # SHORT_VERSION="$(echo $VERSION | rev | cut -d"." -f2- | rev)" + # NUGET_VERSION="$(echo "$VERSION" | tr + .)" + # echo $VERSION + # echo $SHORT_VERSION + # echo $NUGET_VERSION + # SHORT_NUGET_VERSION="$(echo $NUGET_VERSION | rev | cut -d"." -f2- | rev)" + # echo $SHORT_NUGET_VERSION + # SHORTER_NUGET_VERSION="$(echo $SHORT_NUGET_VERSION | rev | cut -d"." -f2- | rev)" + # echo $SHORTER_NUGET_VERSION + # TEST_NUGET_VERSION="$(echo $NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" + # TEST_NUGET_VERSION="$(echo $TEST_NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" + # echo $TEST_NUGET_VERSION + # echo "TEST_NUGET_VERSION=$TEST_NUGET_VERSION" >> "$GITHUB_OUTPUT" + # name: Set the nuget version + # id: set-nuget-version + + # - run: | + # dotnet nuget push \ + # nhs.notify.suppliers.api.data.${TEST_NUGET_VERSION}.nupkg \ + # --source github \ + # --api-key $GITHUB_TOKEN + # env: + # TEST_NUGET_VERSION: ${{ steps.set-nuget-version.outputs.TEST_NUGET_VERSION }} + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # ### PUBLISH LIBS host NUGET + # publishlibdatanuget: + # name: "Publish libs host packages to nuget.pkg.github.com" + # runs-on: ubuntu-latest + # needs: [publish] + # permissions: + # packages: write + # contents: read + # steps: + # - name: "Get the artefacts" + # uses: actions/download-artifact@v5 + # with: + # path: . + # name: libs-host-${{ inputs.version }} + # - run: | + # ls -la + # find . -name ".version" + # - run: | + # dotnet nuget add source \ + # --username nhs-notify-supplier-api \ + # --password ${{ secrets.GITHUB_TOKEN }} \ + # --store-password-in-clear-text \ + # --name github \ + # "https://nuget.pkg.github.com/NHSDigital/index.json" + # - run: | + # echo "ROOT .version file is: $(cat .version)" + # echo "GH variable version is: ${{ inputs.version }}" + # name: Showing the base versions + + # - run: | + # VERSION=${{ inputs.version }} + # SHORT_VERSION="$(echo $VERSION | rev | cut -d"." -f2- | rev)" + # NUGET_VERSION="$(echo "$VERSION" | tr + .)" + # echo $VERSION + # echo $SHORT_VERSION + # echo $NUGET_VERSION + # SHORT_NUGET_VERSION="$(echo $NUGET_VERSION | rev | cut -d"." -f2- | rev)" + # echo $SHORT_NUGET_VERSION + # SHORTER_NUGET_VERSION="$(echo $SHORT_NUGET_VERSION | rev | cut -d"." -f2- | rev)" + # echo $SHORTER_NUGET_VERSION + # TEST_NUGET_VERSION="$(echo $NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" + # TEST_NUGET_VERSION="$(echo $TEST_NUGET_VERSION | sed -E 's/.([^.]*)$/\1/')" + # echo $TEST_NUGET_VERSION + # echo "TEST_NUGET_VERSION=$TEST_NUGET_VERSION" >> "$GITHUB_OUTPUT" + # name: Set the nuget version + # id: set-nuget-version + + # - run: | + # dotnet nuget push \ + # nhs.notify.suppliers.api.host.${TEST_NUGET_VERSION}.nupkg \ + # --source github \ + # --api-key $GITHUB_TOKEN + # env: + # TEST_NUGET_VERSION: ${{ steps.set-nuget-version.outputs.TEST_NUGET_VERSION }} + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # ### PUBLISH LIBS host docker + # publishlibhostdocker: + # name: "Publish libs host docker" + # runs-on: ubuntu-latest + # needs: [publish] + # permissions: + # packages: write + # contents: read + # steps: + # - name: "Get the artefacts" + # uses: actions/download-artifact@v5 + # with: + # path: . + # name: libs-host-docker-${{ inputs.version }} + + # - run: | + # ls -Rla + # docker load --input myimage.tar + # docker image ls -a + # echo $CR_PAT | docker login ghcr.io -u nhs-notify-supplier-api --password-stdin + # docker push ghcr.io/nhsdigital/libshostdocker:latest + # env: + # CR_PAT: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitleaksignore b/.gitleaksignore index 803deb3d..996b4388 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -15,3 +15,4 @@ b1f85a7faf54eaf66074d7a6daa093aefe6b3ebe:sdk/python/pyproject.toml:ipv4:25 93e54b6baa390529aab08d9fd956837f7bb3f30:src/src.sln:ipv4:3 493e54b6baa390529aab08d9fd956837f7bb3f30:src/src.sln:ipv4:3 d8aaf7e033bf78fff491caa148897be266b60f67:src/src.sln:ipv4:3 +e12407e09151898bfd8d049d57eee9db9977d56b:.github/copilot-instructions.md:generic-api-key:213 diff --git a/.tool-versions b/.tool-versions index 7141c23f..0c674acf 100644 --- a/.tool-versions +++ b/.tool-versions @@ -9,6 +9,7 @@ terraform-docs 0.19.0 trivy 0.61.0 vale 3.6.0 poetry 2.1.4 +java openjdk-25.0.1 # ============================================================================== # The section below is reserved for Docker image versions. diff --git a/Makefile b/Makefile index 91e8d688..7f5186ec 100644 --- a/Makefile +++ b/Makefile @@ -11,10 +11,11 @@ dependencies: # Install dependencies needed to build and test the project @Pipel # TODO: Implement installation of your project dependencies build: # Build the project artefact @Pipeline - (cd server && make build) (cd sdk && make build) (cd docs && make build) - (cd src/server && make build) +# Take out for now - might add again in the future +# (cd server && make build) +# (cd src/server && make build) publish: # Publish the project artefact @Pipeline # TODO: Implement the artefact publishing step @@ -24,8 +25,9 @@ deploy: # Deploy the project artefact to the target environment @Pipeline clean:: # Clean-up project resources (main) @Operations rm -f .version (cd sdk && make clean) - (cd server && make clean) - (cd src/server && make clean) +# Take out for now - might add again in the future +# (cd server && make clean) +# (cd src/server && make clean) guard-%: @ if [ "${${*}}" = "" ]; then \ diff --git a/README.md b/README.md index f7c3d1fa..38df7c65 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -## NHS Notify Supplier API +# NHS Notify Supplier API [![1. CI/CD pull request](https://github.com/NHSDigital/nhs-notify-supplier-api/actions/workflows/cicd-1-pull-request.yaml/badge.svg)](https://github.com/NHSDigital/nhs-notify-supplier-api/actions/workflows/cicd-1-pull-request.yaml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=NHSDigital_nhs-notify-supplier-api&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=NHSDigital_nhs-notify-supplier-api) The NHS Notify Supplier API is intended primarily for print suppliers to integrate with the NHS Notify message request queueing system. -It models the concepts needed to configure production of letters and other printed materials to specific specifications, provide proofs of these materials, receive batch production requests, provide details of returned letters and correspondence, and to report on the status of these artifacts and associated management information such as volumes and assocated costs. +It models the concepts needed to configure production of letters and other printed materials to specific specifications, provide proofs of these materials, receive batch production requests, provide details of returned letters and correspondence, and to report on the status of these artifacts and associated management information such as volumes and associated costs. This repository documents the Supplier API specification and provides an SDK with examples and reference client implementations for interacting with it. @@ -16,27 +16,24 @@ This repository documents the Supplier API specification and provides an SDK wit ## Table of Contents - [NHS Notify Supplier API](#nhs-notify-supplier-api) -- [OAS Specifications](#oas-specifications) -- [Table of Contents](#table-of-contents) -- [API Consumers - Getting Started](#api-consumers---getting-started) - - [OAS Specification](#oas-specification) - - [Packages](#packages) - - [Documentation](#documentation) - - [SDK Assets](#sdk-assets) - - [Examples](#examples) -- [API Developers](#api-developers) - - [Documentation](#documentation-1) - - [pre built servers](#pre-built-servers) - - [Setup](#setup) - - [Prerequisites and Configuration](#prerequisites-and-configuration) - - [SDKs](#sdks) - - [Servers](#servers) - - [Libs](#libs) - - [Build](#build) - - [GitHub Actions CI/CD](#github-actions-cicd) - - [CI (Automatic)](#ci-automatic) - - [CD (Manual)](#cd-manual) -- [Licence](#licence) + - [OAS Specifications](#oas-specifications) + - [Table of Contents](#table-of-contents) + - [API Consumers - Getting Started](#api-consumers---getting-started) + - [OAS Specification](#oas-specification) + - [Packages](#packages) + - [Documentation](#documentation) + - [SDK Assets](#sdk-assets) + - [Examples](#examples) + - [API Developers](#api-developers) + - [Setup](#setup) + - [Prerequisites and Configuration](#prerequisites-and-configuration) + - [SDKs](#sdks) + - [Build](#build) + - [Documentation](#documentation-1) + - [GitHub Actions CI/CD](#github-actions-cicd) + - [CI (Automatic)](#ci-automatic) + - [CD (Manual)](#cd-manual) + - [Licence](#licence) ## API Consumers - Getting Started @@ -71,20 +68,7 @@ TODO:CCM-11209 Links to example clients. ## API Developers -New developer of the NHS Notify Supplier API -should understand the below. - -### Documentation - -- [Built](/) -- [Source](/docs/README.md) - -### pre built servers - -- "Working" C# server [/src/server/host](/src/server/host) `docker run -p 8080:8080 ghcr.io/nhsdigital/libshostdocker:latest` - - View at [http://localhost:8080/swagger/index.html](http://localhost:8080/swagger/index.html) -- Docker OAS example Server (csharp) `docker run -p 3000:3000 ghcr.io/nhsdigital/nhsnotifysupplierserver:latest` -- CSharp `server-csharp-[Version].zip` +New developers of the NHS Notify Supplier API should understand the below. ### Setup @@ -102,16 +86,6 @@ should understand the below. and will be built as part of the CI/CD pipeline and released as a GitHub release. -##### Servers - -- Servers folder is being built at build time from OAS specs. -- TODO:CCM-12139 Build actual servers - -##### Libs - -- [/src/server](/src/server) has various separate libaries that are used by: - - [/src/server/host](/src/server/host) custom loads libs for different parts of the server - ### Build To generate the SDK folder from changes to the [specification/api/notify-supplier.yml](specification/api/notify-supplier.yml) OAS specification: @@ -137,6 +111,10 @@ by default they will be available at [http://localhost:3050](http://localhost:30 These are generated using [https://hub.docker.com/r/openapitools/openapi-generator-cli](https://hub.docker.com/r/openapitools/openapi-generator-cli) +### Documentation + +- You can preview the OAS locally by running `make serve-oas` + ### GitHub Actions CI/CD #### CI (Automatic) diff --git a/docs/.gitignore b/docs/.gitignore index 54812bb5..892266c6 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -10,3 +10,4 @@ _config.version.yml # Generated or copied from other repo resources _includes/components/generated/* +assets/swagger/* diff --git a/docs/Makefile b/docs/Makefile index 9ec6f5d1..eee65c92 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,6 +1,7 @@ BASE_URL ?= "/" VERSION ?= "" SHELL = /bin/bash +SDK_DIR := ../sdk default: install @@ -19,10 +20,12 @@ define baseurlparam = $(if $(BASE_URL),-- --baseurl $(BASE_URL),-- --baseurl "") endef -build: version .generate-includes +build: version .generate-includes $(SDK_DIR)/build + rsync -a --delete $(SDK_DIR)/swagger/ ./assets/swagger npm run build $(baseurlparam) -debug: version .generate-includes +debug: version .generate-includes $(SDK_DIR)/build + rsync -a --delete $(SDK_DIR)/swagger/ ./assets/swagger npm run debug version: @@ -41,3 +44,6 @@ version: .generate-includes: npm run generate-includes + +$(SDK_DIR)/build: + $(MAKE) -C $(SDK_DIR) build diff --git a/docs/generate-includes.sh b/docs/generate-includes.sh index 87987688..c3b5649b 100755 --- a/docs/generate-includes.sh +++ b/docs/generate-includes.sh @@ -10,10 +10,5 @@ mkdir -p ./docs/_includes/components/generated npm run -w internal/datastore diagrams cp ./internal/datastore/src/types.md ./docs/_includes/components/generated/types.md -# Specifications -npm run bundle-oas -npm run generate:html -cp ./sdk/html/index.html ./docs/_includes/components/generated/nhs-notify-supplier-api.html - #Contributing file cp ./CONTRIBUTING.md ./docs/_includes/components/generated/contributing.md diff --git a/docs/pages/specification.html b/docs/pages/specification.html index 7f2e0941..3b862cf3 100644 --- a/docs/pages/specification.html +++ b/docs/pages/specification.html @@ -14,4 +14,10 @@ permalink: /specification --- -{% include components/generated/nhs-notify-supplier-api.html %} +
+ +
diff --git a/sdk/Makefile b/sdk/Makefile index 91bce278..76092481 100644 --- a/sdk/Makefile +++ b/sdk/Makefile @@ -8,6 +8,7 @@ build: version # Build the project artefact @Pipeline clean: # Clean-up project resources (main) @Operations rm -rf */ + swagger: ./swagger.sh diff --git a/sdk/swagger-initializer.js b/sdk/swagger-initializer.js index 7ea35f52..600ade2f 100644 --- a/sdk/swagger-initializer.js +++ b/sdk/swagger-initializer.js @@ -3,7 +3,7 @@ window.onload = function() { // the following lines will be replaced by docker/configurator, when it runs in a docker-container window.ui = SwaggerUIBundle({ - urls: [{url:"swagger.json", name: "current"}], + urls: [{url:"swagger.yml", name: "current"}], dom_id: '#swagger-ui', deepLinking: true, presets: [ diff --git a/sdk/swagger-static.sh b/sdk/swagger-static.sh index 5c418161..806c55d5 100755 --- a/sdk/swagger-static.sh +++ b/sdk/swagger-static.sh @@ -9,5 +9,5 @@ unzip swagger.zip "swagger-ui-$VERSION/dist/*" -d swagger mv swagger/swagger-ui-$VERSION/dist/* swagger rm -r swagger/swagger-ui-$VERSION cp swagger-initializer.js swagger/swagger-initializer.js -cp ../specification/api/notify-supplier-phase1.yml swagger/swagger.json +cp ../build/notify-supplier.yml swagger/swagger.yml rm swagger.zip diff --git a/sdk/swagger.sh b/sdk/swagger.sh index a77b4bae..25585d41 100755 --- a/sdk/swagger.sh +++ b/sdk/swagger.sh @@ -1,3 +1,4 @@ #!/bin/sh +set -eux -docker run -p 80:8080 -e SWAGGER_JSON=/swagger/swagger.json -v ../specification/api/notify-supplier.yml:/swagger/swagger.json docker.swagger.io/swaggerapi/swagger-ui +docker run -p 80:8080 -e SWAGGER_JSON=/swagger/swagger.yml -v ../build/notify-supplier.yml:/swagger/swagger.yml docker.swagger.io/swaggerapi/swagger-ui diff --git a/server/Makefile b/server/Makefile index 780ce990..7408b0ac 100644 --- a/server/Makefile +++ b/server/Makefile @@ -7,8 +7,6 @@ build: version # Build the project artefact @Pipeline clean: # Clean-up project resources (main) @Operations rm -rf */ -swagger: - ./swagger.sh version: touch _config.version.yml