diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 87eed32..c7e3ebf 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -4,11 +4,9 @@ on: pull_request: branches: - main - - master push: branches: - main - - master jobs: analyze-commits: @@ -44,7 +42,6 @@ jobs: release-tag: ${{ steps.next-version.outputs.release-tag }} release-version: ${{ steps.next-version.outputs.release-version }} - docker: uses: ./.github/workflows/docker-build-and-push-workflow.yml needs: analyze-commits @@ -53,26 +50,58 @@ jobs: version: ${{ needs.analyze-commits.outputs.release-version }} publish: >- ${{ (startsWith(github.ref, 'refs/tags/') || - github.ref == 'refs/heads/main' || - github.ref == 'refs/heads/master') && + github.ref == 'refs/heads/main') && github.event_name == 'push' }} docker-image-repo: ${{ vars.DOCKER_IMAGE_REPOSITORY }} upload-sarif-to-security: >- ${{ (startsWith(github.ref, 'refs/tags/') || - github.ref == 'refs/heads/main' || - github.ref == 'refs/heads/master') && + github.ref == 'refs/heads/main') && github.event_name == 'push' }} + release: + runs-on: ubuntu-latest + needs: + - docker + - analyze-commits + steps: + - + name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - + name: Update BuildInfo.properties if there is a version + run: /bin/bash .github/workflows/writeBuildInfo.sh ${{ needs.analyze-commits.outputs.release-version }} + - + name: "🔧 setup node" + uses: actions/setup-node@v2.1.5 + with: + node-version: 18.x + - + name: Install dependencies + run: yarn global add semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github @semantic-release/exec @semantic-release/release-notes-generator @semantic-release/commit-analyzer conventional-changelog-conventionalcommits + - + name: Semantic Release + run: "semantic-release" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + publish-docker: runs-on: ubuntu-latest needs: - - docker + - release + - analyze-commits if: >- - ${{ (startsWith(github.ref, 'refs/tags/') || - github.ref == 'refs/heads/main' || - github.ref == 'refs/heads/master') && - github.event_name == 'push' }} + (startsWith(github.ref, 'refs/tags/') || + github.ref == 'refs/heads/main') && + github.event_name == 'push' && + needs.analyze-commits.outputs.release-version != '' && + needs.analyze-commits.outputs.release-version != null steps: + - + name: Show release version + run: echo "Pushing docker image for version ${{ needs.analyze-commits.outputs.release-version }}" - name: Checkout uses: actions/checkout@v3 @@ -100,26 +129,3 @@ jobs: name: Push Docker image run: docker push ${{ vars.DOCKER_IMAGE_REPOSITORY }} --all-tags - release: - runs-on: ubuntu-latest - needs: publish-docker - steps: - - - name: Checkout - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: "🔧 setup node" - uses: actions/setup-node@v2.1.5 - with: - node-version: 18.x - - - name: Install dependencies - run: yarn global add semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github @semantic-release/exec @semantic-release/release-notes-generator @semantic-release/commit-analyzer conventional-changelog-conventionalcommits - - - name: Semantic Release - run: "semantic-release" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/docker-build-and-push-workflow.yml b/.github/workflows/docker-build-and-push-workflow.yml index 70e9027..2d0a68f 100644 --- a/.github/workflows/docker-build-and-push-workflow.yml +++ b/.github/workflows/docker-build-and-push-workflow.yml @@ -20,7 +20,7 @@ on: type: boolean required: false description: Add latest flavor - default: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }} + default: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} upload-sarif-to-security: type: boolean required: false @@ -37,6 +37,9 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - + name: Update BuildInfo.properties if there is a version + run: /bin/bash .github/workflows/writeBuildInfo.sh ${{ inputs.version }} - name: Extract Docker metadata id: meta diff --git a/.github/workflows/writeBuildInfo.sh b/.github/workflows/writeBuildInfo.sh index cd82028..d757e45 100644 --- a/.github/workflows/writeBuildInfo.sh +++ b/.github/workflows/writeBuildInfo.sh @@ -1,3 +1,9 @@ #!/bin/bash -echo "version=$1" > src/main/configurations/LopendeZaken/BuildInfo.properties +if [[ -n $1 ]]; then + echo "writeBuildInfo.sh - writing version $1" + echo "version=$1" > src/main/configurations/LopendeZaken/BuildInfo.properties + echo "versionDate_ddmmyyyy=$(date +%d/%m/%Y)" >> src/main/configurations/LopendeZaken/BuildInfo.properties +else + echo "writeBuildInfo.sh - no version to write, leaving BuildInfo.properties unchanged" +fi \ No newline at end of file