From 65b97c9b417ea139d50e0990e51555e406b8fa84 Mon Sep 17 00:00:00 2001 From: cmendible <266546+cmendible@users.noreply.github.com> Date: Fri, 15 Dec 2023 10:48:58 +0100 Subject: [PATCH] added release job --- .github/workflows/main.yaml | 67 ++++++++++++++++++++++++++++++-- modules/onpremises_tests/main.tf | 2 +- tests/Dockerfile | 1 + tests/scripts/run.sh | 2 +- 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index df8eba8..80b324d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - v* pull_request: branches: - main @@ -12,6 +14,7 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} + AGW_ARTIFACT_NAME: agw-pep-custom-names-tf-modules jobs: tfsec: @@ -43,10 +46,11 @@ jobs: recursive: "true" recursive-path: "modules" git-push: "true" + build-tests: name: Build tests runs-on: ubuntu-latest - needs: docs + needs: tfsec steps: - name: Checkout uses: actions/checkout@v3 @@ -82,8 +86,9 @@ jobs: context: . file: ./tests/Dockerfile push: ${{ github.event_name != 'pull_request' }} - tags: ${{ env.REGISTRY }}/${{ env.GITHUB_REPOSITORY_LOWER_CASE }}/agwpepcustomnames:${{ env.MINVERVERSIONOVERRIDE }} + tags: ${{ env.REGISTRY }}/${{ env.GITHUB_REPOSITORY_LOWER_CASE }}/agw-pep-custom-names:${{ env.MINVERVERSIONOVERRIDE }} labels: ${{ steps.meta.outputs.labels }} + artifacts: name: Create artifacts runs-on: ubuntu-latest @@ -104,8 +109,64 @@ jobs: - name: Upload Artifacts uses: actions/upload-artifact@v3 with: - name: agw-tests-${{ env.MINVERVERSIONOVERRIDE }} + name: ${{ env.AGW_ARTIFACT_NAME }} path: | ./modules/ ./*.tf ./*.md + + release: + name: Create Release + needs: artifacts + if: github.event_name != 'pull_request' && startswith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + permissions: write-all + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: release + uses: actions/create-release@v1 + id: create_release + with: + tag_name: ${{ github.ref }} + release_name: ${{ env.MINVERVERSIONOVERRIDE }} + body: ${{ steps.changelog.outputs.clean_changelog }} + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ github.token }} + + publish: + name: Publish binaries + needs: release + permissions: write-all + if: github.event_name != 'pull_request' && startswith(github.ref, 'refs/tags/v') + env: + ARTIFACT_DIR: ${{ github.workspace }}/release + PROJECT_NAME: agw-pep-custom-names + runs-on: ubuntu-latest + steps: + - name: download artifacts - ${{ env.AGW_ARTIFACT_NAME }} + uses: actions/download-artifact@v3 + with: + name: ${{ env.AGW_ARTIFACT_NAME }} + path: ${{ env.ARTIFACT_DIR }}/${{ env.AGW_ARTIFACT_NAME }} + + - name: Creating Zip + run: zip -r ${{ env.AGW_ARTIFACT_NAME }}.zip ${{ env.ARTIFACT_DIR }}/${{ env.AGW_ARTIFACT_NAME }}/* + + - name: upload artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ needs.release.outputs.upload_url }} + asset_path: ${{ env.AGW_ARTIFACT_NAME }}.zip + asset_name: ${{ env.AGW_ARTIFACT_NAME }}.zip + asset_content_type: application/octet-stream + diff --git a/modules/onpremises_tests/main.tf b/modules/onpremises_tests/main.tf index 7dc63d5..7113546 100644 --- a/modules/onpremises_tests/main.tf +++ b/modules/onpremises_tests/main.tf @@ -16,7 +16,7 @@ resource "azurerm_container_group" "tests" { container { name = "${var.contaner_group_name}-container" - image = "cmendibl3/aurora" + image = "ghcr.io/azure/agw-pep-custom-names/agw-pep-custom-names:1.0.0" cpu = "1.0" memory = "1.0" commands = [] diff --git a/tests/Dockerfile b/tests/Dockerfile index ad050f7..1f7c38f 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -14,5 +14,6 @@ COPY "./tests/Aurora.Tests.csproj" . RUN dotnet restore Aurora.Tests.csproj COPY ./tests/ . +RUN chmod +x ./scripts/run.sh RUN dotnet build Aurora.Tests.csproj -c Release ENTRYPOINT ["./scripts/run.sh"] \ No newline at end of file diff --git a/tests/scripts/run.sh b/tests/scripts/run.sh index 9f67230..bb8276c 100644 --- a/tests/scripts/run.sh +++ b/tests/scripts/run.sh @@ -1,4 +1,4 @@ #! /bin/sh -dotnet test -c Release --no-build -l "trx;LogFileName=TestResults.trx" +dotnet test Aurora.Tests.csproj -c Release --no-build -l "trx;LogFileName=TestResults.trx" cat ./TestResults/TestResults.trx sleep 3600