Merge pull request #1021 from SoftFx/fix/alert-schedule-bugs #2060
This file contains hidden or 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: HSMServer build | |
| on: | |
| push: | |
| branches: [master, develop] | |
| workflow_dispatch: | |
| inputs: | |
| isPreRelease: | |
| description: "PreRelease" | |
| type: boolean | |
| required: true | |
| default: false | |
| env: | |
| OUTPUT_FOLDER: ${{ github.workspace }}/BuildOutput | |
| SOLUTION_PATH: src/server/HSMServer/HSMServer.sln | |
| SERVER_PATH: src/server/HSMServer/HSMServer.csproj | |
| DOCKER_DOCKERHUB_ORG: hsmonitoring | |
| DOCKER_DEPS_REPOS: hierarchical_sensor_monitoring_deps | |
| DOCKER_MAIN_REPOS: hierarchical_sensor_monitoring | |
| LATEST_TAG: latest | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| outputs: | |
| VERSION: ${{ steps.save-version.outputs.version }} | |
| ARTIFACT_NAME: ${{ steps.build-artifact-name.outputs.name}} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET Core | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| run: dotnet restore ${{ env.SOLUTION_PATH }} | |
| - name: Build & Test Solution | |
| run: dotnet test ${{ env.SOLUTION_PATH }} --no-restore -c Release | |
| - name: Publish HSMServer | |
| run: dotnet publish ${{ env.SERVER_PATH }} -c Release -o ${{ env.OUTPUT_FOLDER }} | |
| - id: save-version | |
| name: Try to get server version | |
| run: echo "version=$((Get-Item ${{ env.OUTPUT_FOLDER }}/HSMServer.exe).VersionInfo.ProductVersion)" >> $env:GITHUB_OUTPUT | |
| - id: build-artifact-name | |
| name: Build artifact name | |
| run: echo "name=HSMServer v${{ steps.save-version.outputs.version }}" >> $env:GITHUB_OUTPUT | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: ${{ env.OUTPUT_FOLDER }} | |
| name: ${{ steps.build-artifact-name.outputs.name }} | |
| create-tag: | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| outputs: | |
| BUILD_TAG: ${{ steps.save-tag.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: save-tag | |
| name: Create tag | |
| run: echo "tag=server-v${{ needs.build.outputs.VERSION }}" >> $GITHUB_OUTPUT | |
| - name: Build release tag message | |
| if: ${{ github.event.inputs.isPreRelease == 'false' }} | |
| run: echo "TagMessage=Release version HSMServer-${{ needs.build.outputs.VERSION }}" >> $GITHUB_ENV | |
| - name: Build prerelease tag message | |
| if: ${{ github.event.inputs.isPreRelease == 'true' }} | |
| run: echo "TagMessage=PreRelease version HSMServer-${{ needs.build.outputs.VERSION }} for developers" >> $GITHUB_ENV | |
| - name: Push tag | |
| uses: rickstaa/action-create-tag@v1 | |
| with: | |
| tag: ${{ steps.save-tag.outputs.tag }} | |
| message: ${{ env.TagMessage }} | |
| force_push_tag: true | |
| create-release: | |
| runs-on: ubuntu-latest | |
| needs: [build, create-tag] | |
| env: | |
| ReleaseNote: "ReleaseNote.md" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ needs.build.outputs.ARTIFACT_NAME }} | |
| path: ${{ env.OUTPUT_FOLDER }} | |
| - name: Create archive name | |
| run: echo "ArtifactZip=HSMServer-${{ needs.build.outputs.VERSION }}.zip" >> $GITHUB_ENV | |
| - name: Check archive name | |
| run: echo $ArtifactZip | |
| - name: Archive artifacts | |
| uses: thedoctor0/zip-release@main | |
| with: | |
| type: "zip" | |
| path: ${{ env.OUTPUT_FOLDER }} | |
| filename: ${{ env.ArtifactZip }} | |
| - name: Create release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| name: ${{ needs.build.outputs.ARTIFACT_NAME }} | |
| tag: ${{ needs.create-tag.outputs.BUILD_TAG }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| artifacts: ${{ env.ArtifactZip }} | |
| prerelease: ${{ github.event.inputs.isPreRelease }} | |
| bodyFile: ${{ env.ReleaseNote }} | |
| allowUpdates: true | |
| publish-docker-deps: | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| runs-on: ubuntu-latest | |
| environment: DockerHub | |
| env: | |
| DockerfilePath: .github/docker/dockerfile_deps | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUBUSERNAME }} | |
| password: ${{ secrets.DOCKERHUBTOKEN }} | |
| - name: Build and push docker deps | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| file: ${{ env.DockerfilePath }} | |
| tags: ${{ env.DOCKER_DOCKERHUB_ORG }}/${{ env.DOCKER_DEPS_REPOS }}:${{ env.LATEST_TAG }} | |
| publish-docker-image: | |
| runs-on: ubuntu-latest | |
| environment: DockerHub | |
| needs: [publish-docker-deps, build] | |
| env: | |
| DockerHubDepsRegistry: index.docker.io | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to Docker Hub for deps repos pull | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.DockerHubDepsRegistry }} | |
| username: ${{ secrets.DOCKERHUBUSERNAME }} | |
| password: ${{ secrets.DOCKERHUBTOKEN }} | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUBUSERNAME }} | |
| password: ${{ secrets.DOCKERHUBTOKEN }} | |
| - name: Build full deps url | |
| run: echo "DockerDepsUrl=${{ env.DockerHubDepsRegistry }}/${{ env.DOCKER_DOCKERHUB_ORG }}/${{ env.DOCKER_DEPS_REPOS }}:${{ env.LATEST_TAG }}" >> $GITHUB_ENV | |
| - name: Build full main repos name | |
| run: echo "DockerMainName=${{ env.DOCKER_DOCKERHUB_ORG }}/${{ env.DOCKER_MAIN_REPOS }}" >> $GITHUB_ENV | |
| - name: Build Linux image for Docker | |
| run: dotnet publish ${{ env.SERVER_PATH }} -c Release --os linux --arch x64 -p:PublishProfile=DefaultContainer -p:ContainerBaseImage=${{ env.DockerDepsUrl }} -p:ContainerImageName=${{ env.DockerMainName }} | |
| - name: Push VERSION image to remote Docker | |
| run: docker push "${{ env.DockerMainName }}:${{ needs.build.outputs.VERSION }}" | |
| - name: Push LATEST image to remote Docker | |
| if: ${{ github.event.inputs.isPreRelease == 'false' }} | |
| run: docker push "${{ env.DockerMainName }}:${{ env.LATEST_TAG }}" |