diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c77c321dab5d255bbe8972c1e820bb5c8a0bd97c..2a185d11d608adf6a16ae263aa10ecebb4b78202 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,27 +11,45 @@ env: HARBOR_REGISTRY: registry.cern.ch jobs: - get-tag-name: + get-version: + if: github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest outputs: - tag_name: ${{ steps.release-on-push.outputs.tag_name }} + tag_name: ${{ steps.get-tag-name.outputs.tag_name }} steps: - - name: Get the tag name generated by the release-on-push workflow - id: release-on-push - uses: actions/github-script@v4 + - name: Download artifact + uses: actions/github-script@v6 with: - github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const last_release = await github.repos.getLatestRelease({ - owner: context.repo.owner, - repo: context.repo.repo, + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, }); - const last_release_tag = last_release.data.tag_name; - core.setOutput("tag_name", last_release_tag); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "version_number" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/version_number.zip`, Buffer.from(download.data)); + + - name: Unzip artifact + run: unzip version_number.zip + + - name: Get tag name + id: get-tag-name + run: | + echo "tag_name=$(cat version_number)" >> $GITHUB_OUTPUT build-and-push-to-github: runs-on: ubuntu-latest - needs: get-tag-name + needs: get-version + if: needs.get-version.outputs.tag_name != '' steps: - name: Checkout repository uses: actions/checkout@v3 @@ -47,13 +65,14 @@ jobs: run: | docker compose -f docker-compose.yml -f docker-compose.github.yml build docker compose -f docker-compose.yml -f docker-compose.github.yml push - export tag=${{ needs.get-tag-name.outputs.tag_name }} + export tag=${{ needs.get-version.outputs.tag_name }} docker compose -f docker-compose.yml -f docker-compose.github.yml build docker compose -f docker-compose.yml -f docker-compose.github.yml push build-and-push-to-harbor: runs-on: ubuntu-latest - needs: get-tag-name + needs: get-version + if: needs.get-version.outputs.tag_name != '' steps: - name: Checkout repository uses: actions/checkout@v3 @@ -69,6 +88,6 @@ jobs: run: | docker compose -f docker-compose.yml -f docker-compose.harbor.yml build docker compose -f docker-compose.yml -f docker-compose.harbor.yml push - export tag=${{ needs.get-tag-name.outputs.tag_name }} + export tag=${{ needs.get-version.outputs.tag_name }} docker compose -f docker-compose.yml -f docker-compose.harbor.yml build docker compose -f docker-compose.yml -f docker-compose.harbor.yml push diff --git a/.github/workflows/pull-request-labels.yaml b/.github/workflows/pull-request-labels.yaml index 05e5057d910572282c8a7fd47cb5d58206c57948..c0b70b674a72d1d1870bc7cb4b5694153a75a5cf 100644 --- a/.github/workflows/pull-request-labels.yaml +++ b/.github/workflows/pull-request-labels.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 @@ -21,19 +21,19 @@ jobs: - name: Get the label to add id: get_label - uses: actions/github-script@v3 + uses: actions/github-script@v6 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const labels = ["release:patch", "release:minor", "release:major"]; - const last_release = await github.repos.getLatestRelease({ + const labels = ["release:patch", "release:minor", "release:major", "norelease"]; + const last_release = await github.rest.repos.getLatestRelease({ owner: context.repo.owner, repo: context.repo.repo, }); const last_release_tag = last_release.data.tag_name; const last_release_version = last_release_tag.replace("v", ""); if (last_release_version === process.env.VERSION) { - core.setFailed("The version has not been bumped"); + core.setOutput("label", labels[3]); } else { const last_release_version_split = last_release_version.split("."); const current_version_split = process.env.VERSION.split("."); diff --git a/.github/workflows/release-on-push.yml b/.github/workflows/release-on-push.yml index 8e48c503d9c2a97d81ee373d222403107c851199..68fe9dcd42dcafc80424956e0f79524eb80e27e9 100644 --- a/.github/workflows/release-on-push.yml +++ b/.github/workflows/release-on-push.yml @@ -16,7 +16,7 @@ jobs: id: release uses: rymndhng/release-on-push-action@master with: - bump_version_scheme: patch + bump_version_scheme: "norelease" tag_prefix: v release_name: <RELEASE_TAG> max_commits: 25 @@ -26,3 +26,16 @@ jobs: outputs: tag_name: ${{ steps.release.outputs.tag_name }} version: ${{ steps.release.outputs.version }} + + store-version: + needs: release-on-push + runs-on: ubuntu-latest + steps: + - name: Save version + run: | + mkdir -p ./version + echo "${{ needs.release-on-push.outputs.version }}" > ./version/version_number + - uses: actions/upload-artifact@v2 + with: + name: version_number + path: ./version