From 321a28a0385a3e0e575317430bfe0aec64fb3afc Mon Sep 17 00:00:00 2001 From: MichalKinas Date: Mon, 27 May 2024 07:36:54 +0200 Subject: [PATCH 1/5] [ACS-7241] Parallel releases support v1 --- .github/actions/get-image-tag/action.yml | 2 +- .github/actions/git-tag/action.yml | 2 +- .github/actions/setup/action.yml | 40 +++++++---- .github/workflows/release-branch.yml | 87 ---------------------- .github/workflows/release.yml | 91 +++++++++++++++++++++++- 5 files changed, 115 insertions(+), 107 deletions(-) delete mode 100644 .github/workflows/release-branch.yml diff --git a/.github/actions/get-image-tag/action.yml b/.github/actions/get-image-tag/action.yml index 8ee539109d..77797ef064 100644 --- a/.github/actions/get-image-tag/action.yml +++ b/.github/actions/get-image-tag/action.yml @@ -13,7 +13,7 @@ runs: - name: Get docker image tag name shell: bash run: | - if [[ "${{ inputs.branch_name }}" == "master" ]]; then + if [[ "${{ inputs.branch_name }}" == "master" ]] || [[ "${{ inputs.branch_name }}" == release/* ]]; then TAG_VERSION="$(jq -cr '.version' < package.json)" else TAG_VERSION="${{ inputs.branch_name }}-${{ github.run_id }}" diff --git a/.github/actions/git-tag/action.yml b/.github/actions/git-tag/action.yml index 99e0017058..c18cc64f09 100644 --- a/.github/actions/git-tag/action.yml +++ b/.github/actions/git-tag/action.yml @@ -21,7 +21,7 @@ runs: - name: publish tag shell: bash run: | - if [[ "${{ inputs.branch_name }}" == "master" ]]; then + if [[ "${{ inputs.branch_name }}" == "master" ]] || [[ "${{ inputs.branch_name }}" == release/* ]]; then VERSION=$(jq -cr '.version' < package.json) echo "git tag -a ${VERSION} -m ${VERSION}" diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index dd22359ac5..9531bc44c6 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,6 +1,12 @@ name: "Variables setup" description: "Variables setup" +inputs: + npm_tag: + description: 'NPM tag' + required: false + type: string + runs: using: "composite" steps: @@ -17,23 +23,27 @@ runs: - name: set TAG_NPM shell: bash run: | - TAG_NPM="alpha" - VERSION_IN_PACKAGE_JSON=$(jq -cr '.version' < package.json) + if [[ -n "${{ inputs.npm_tag }}" ]]; then + TAG_NPM=${{ inputs.npm_tag }} + else + TAG_NPM="alpha" + VERSION_IN_PACKAGE_JSON=$(jq -cr '.version' < package.json) - echo "version in package.json=${VERSION_IN_PACKAGE_JSON}" + echo "version in package.json=${VERSION_IN_PACKAGE_JSON}" - if [[ $BRANCH_NAME =~ ^master(-patch.*)?$ ]]; then - # Pre-release versions - if [[ $VERSION_IN_PACKAGE_JSON =~ ^[0-9]*\.[0-9]*\.[0-9]*-A\.[0-9]*$ ]]; - then - TAG_NPM=next - # Stable major versions - else - TAG_NPM=latest - fi - fi + if [[ $BRANCH_NAME =~ ^master(-patch.*)?$ ]] || [[ $BRANCH_NAME == release/* ]]; then + # Pre-release versions + if [[ $VERSION_IN_PACKAGE_JSON =~ ^[0-9]*\.[0-9]*\.[0-9]*-A\.[0-9]*$ ]]; + then + TAG_NPM=next + # Stable major versions + else + TAG_NPM=latest + fi + fi - if [[ $BRANCH_NAME =~ ^develop(-patch.*)?$ ]]; then - TAG_NPM=alpha + if [[ $BRANCH_NAME =~ ^develop(-patch.*)?$ ]]; then + TAG_NPM=alpha + fi fi echo "TAG_NPM=${TAG_NPM}" >> $GITHUB_ENV diff --git a/.github/workflows/release-branch.yml b/.github/workflows/release-branch.yml deleted file mode 100644 index add3dc9580..0000000000 --- a/.github/workflows/release-branch.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Release ACA libs from branch -run-name: Release ACA libs from branch ${{ github.ref_name }} - -on: - workflow_dispatch: - inputs: - dry-run-flag: - description: 'enable dry-run' - required: false - type: boolean - default: true - -env: - BASE_URL: ${{ secrets.PIPELINE_ENV_URL }} - -jobs: - lint: - name: 'lint' - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: node - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: 'npm' - - run: npm ci - - run: npm run affected:lint -- --base=origin/develop - - run: npm run stylelint - - unit-tests: - needs: [lint] - name: "Unit tests: ${{ matrix.unit-tests.name }}" - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - unit-tests: - - name: "aca-content" - - name: "aca-shared" - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: node - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: 'npm' - - uses: ./.github/actions/before-install - - run: npm ci - - run: npm run affected:test -- --browsers=ChromeHeadless --watch=false $TEST_OPTS --base=origin/develop - - publish-libs: - needs: [lint, unit-tests] - name: "Publish libs to NPM and GitHub registry" - runs-on: ubuntu-latest - permissions: - packages: write - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: 'npm' - - - uses: Alfresco/alfresco-build-tools/.github/actions/get-branch-name@v8.4.0 - - - name: publish - uses: ./.github/actions/publish-libs - with: - branch_name: ${{ env.BRANCH_NAME }} - github_token: ${{ secrets.BOT_GITHUB_TOKEN }} - npm_registry_token: ${{ secrets.NPM_REGISTRY_TOKEN }} - npm_tag: 'branch' - dry-run: ${{ inputs.dry-run-flag }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 090f9bd1aa..2de13b452b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,36 @@ -name: "Release" +name: Release workflow +run-name: Release workflow triggered from ${{ github.ref_name }} branch on: workflow_dispatch: inputs: + publish-to-docker: + description: 'Publish to Docker' + required: false + type: boolean + default: true + publish-to-quay: + description: 'Publish to Quay' + required: false + type: boolean + default: true + publish-to-npm: + description: 'Publish NPM libraries' + required: false + type: boolean + default: true + publish-git-tag: + description: 'Publish Git Tag' + required: false + type: boolean + default: true + npm-tag: + description: 'NPM tag that libraries will be published with' + required: false + type: string + default: '' dry-run-release: - description: 'enable dry-run' + description: 'Enable dry-run' required: false type: boolean default: true @@ -12,6 +38,7 @@ on: branches: - master - develop + - release/** env: BASE_URL: ${{ secrets.PIPELINE_ENV_URL }} @@ -20,7 +47,53 @@ env: PLAYWRIGHT_E2E_HOST: ${{ secrets.PLAYWRIGHT_E2E_HOST }} jobs: + lint: + if: github.event_name == 'workflow_dispatch' + name: 'lint' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'npm' + - run: npm ci + - run: npm run affected:lint -- --base=origin/develop + - run: npm run stylelint + + unit-tests: + if: github.event_name == 'workflow_dispatch' + needs: [lint] + name: "Unit tests: ${{ matrix.unit-tests.name }}" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + unit-tests: + - name: "aca-content" + - name: "aca-shared" + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: node + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'npm' + - uses: ./.github/actions/before-install + - run: npm ci + - run: npm run affected:test -- --browsers=ChromeHeadless --watch=false $TEST_OPTS --base=origin/develop + publish-docker-registry: + if: ${{ github.event.inputs.publish-to-quay }} name: "Publish to Quay" runs-on: ubuntu-latest steps: @@ -34,6 +107,8 @@ jobs: node-version-file: '.nvmrc' cache: 'npm' - uses: ./.github/actions/setup + with: + npm_tag: ${{ inputs.npm-tag }} - name: Get Tag uses: ./.github/actions/get-image-tag @@ -50,6 +125,7 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-to-dockerhub: + if: ${{ github.event.inputs.publish-to-docker }} name: "Publish to Dockerhub" runs-on: ubuntu-latest steps: @@ -63,6 +139,8 @@ jobs: node-version-file: '.nvmrc' cache: 'npm' - uses: ./.github/actions/setup + with: + npm_tag: ${{ inputs.npm-tag }} - name: Get Tag uses: ./.github/actions/get-image-tag @@ -79,6 +157,7 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-git-tag: + if: ${{ github.event.inputs.publish-git-tag }} name: "Publish Git Tag" runs-on: ubuntu-latest steps: @@ -91,8 +170,11 @@ jobs: with: node-version-file: '.nvmrc' cache: 'npm' - - uses: ./.github/actions/setup - uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v8.4.0 + - uses: ./.github/actions/setup + with: + npm_tag: ${{ inputs.npm-tag }} + - uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.35.0 with: username: ${{ vars.BOT_GITHUB_USERNAME }} email: ${{ vars.BOT_GITHUB_EMAIL }} @@ -105,6 +187,7 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-libs: + if: ${{ github.event.inputs.publish-to-npm }} name: "Publish libs to NPM and GitHub registry" runs-on: ubuntu-latest permissions: @@ -122,6 +205,8 @@ jobs: cache: 'npm' - uses: ./.github/actions/setup + with: + npm_tag: ${{ inputs.npm-tag }} - name: publish uses: ./.github/actions/publish-libs From b4f083959dad1337117a7c2bb3c6ec9dbf2aad3b Mon Sep 17 00:00:00 2001 From: MichalKinas Date: Mon, 27 May 2024 08:27:59 +0200 Subject: [PATCH 2/5] [ACS-7241] Add missing needs clauses --- .github/workflows/release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2de13b452b..0e12d5d507 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -94,6 +94,7 @@ jobs: publish-docker-registry: if: ${{ github.event.inputs.publish-to-quay }} + needs: [lint, unit-tests] name: "Publish to Quay" runs-on: ubuntu-latest steps: @@ -126,6 +127,7 @@ jobs: publish-to-dockerhub: if: ${{ github.event.inputs.publish-to-docker }} + needs: [lint, unit-tests] name: "Publish to Dockerhub" runs-on: ubuntu-latest steps: @@ -158,6 +160,7 @@ jobs: publish-git-tag: if: ${{ github.event.inputs.publish-git-tag }} + needs: [lint, unit-tests] name: "Publish Git Tag" runs-on: ubuntu-latest steps: @@ -188,6 +191,7 @@ jobs: publish-libs: if: ${{ github.event.inputs.publish-to-npm }} + needs: [lint, unit-tests] name: "Publish libs to NPM and GitHub registry" runs-on: ubuntu-latest permissions: From a174dc4eb24c06f22a3c1152077f0294236ddbe2 Mon Sep 17 00:00:00 2001 From: MichalKinas Date: Mon, 27 May 2024 08:40:19 +0200 Subject: [PATCH 3/5] [ACS-7241] Proper conditional job check --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e12d5d507..ecf554a750 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,7 +93,7 @@ jobs: - run: npm run affected:test -- --browsers=ChromeHeadless --watch=false $TEST_OPTS --base=origin/develop publish-docker-registry: - if: ${{ github.event.inputs.publish-to-quay }} + if: ${{ github.event.inputs.publish-to-quay == 'true' }} needs: [lint, unit-tests] name: "Publish to Quay" runs-on: ubuntu-latest @@ -126,7 +126,7 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-to-dockerhub: - if: ${{ github.event.inputs.publish-to-docker }} + if: ${{ github.event.inputs.publish-to-docker == 'true' }} needs: [lint, unit-tests] name: "Publish to Dockerhub" runs-on: ubuntu-latest @@ -159,7 +159,7 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-git-tag: - if: ${{ github.event.inputs.publish-git-tag }} + if: ${{ github.event.inputs.publish-git-tag == 'true' }} needs: [lint, unit-tests] name: "Publish Git Tag" runs-on: ubuntu-latest @@ -190,7 +190,7 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-libs: - if: ${{ github.event.inputs.publish-to-npm }} + if: ${{ github.event.inputs.publish-to-npm == 'true' }} needs: [lint, unit-tests] name: "Publish libs to NPM and GitHub registry" runs-on: ubuntu-latest From 2608b27b45e5d88efa17d8b27f1eee56b2972430 Mon Sep 17 00:00:00 2001 From: MichalKinas Date: Mon, 27 May 2024 08:48:36 +0200 Subject: [PATCH 4/5] [ACS-7241] Revert testing changes, namespace fix --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ecf554a750..488e1768f3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,7 +93,7 @@ jobs: - run: npm run affected:test -- --browsers=ChromeHeadless --watch=false $TEST_OPTS --base=origin/develop publish-docker-registry: - if: ${{ github.event.inputs.publish-to-quay == 'true' }} + if: ${{ inputs.publish-to-quay == 'true' }} needs: [lint, unit-tests] name: "Publish to Quay" runs-on: ubuntu-latest @@ -126,7 +126,7 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-to-dockerhub: - if: ${{ github.event.inputs.publish-to-docker == 'true' }} + if: ${{ inputs.publish-to-docker == 'true' }} needs: [lint, unit-tests] name: "Publish to Dockerhub" runs-on: ubuntu-latest @@ -159,7 +159,7 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-git-tag: - if: ${{ github.event.inputs.publish-git-tag == 'true' }} + if: ${{ inputs.publish-git-tag == 'true' }} needs: [lint, unit-tests] name: "Publish Git Tag" runs-on: ubuntu-latest @@ -190,7 +190,7 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-libs: - if: ${{ github.event.inputs.publish-to-npm == 'true' }} + if: ${{ inputs.publish-to-npm == 'true' }} needs: [lint, unit-tests] name: "Publish libs to NPM and GitHub registry" runs-on: ubuntu-latest From aaf37849d7c4b3b9ba1f966c69996ada24a7f8e2 Mon Sep 17 00:00:00 2001 From: MichalKinas Date: Tue, 10 Dec 2024 09:36:14 +0100 Subject: [PATCH 5/5] [ACS-7241] Add improved conditions --- .github/workflows/release.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 488e1768f3..658ef98f7f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,12 +53,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'npm' @@ -79,12 +79,12 @@ jobs: - name: "aca-shared" steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'npm' @@ -93,7 +93,9 @@ jobs: - run: npm run affected:test -- --browsers=ChromeHeadless --watch=false $TEST_OPTS --base=origin/develop publish-docker-registry: - if: ${{ inputs.publish-to-quay == 'true' }} + if: | + always() && + (${{ inputs.publish-to-quay == 'true' }} && (needs.unit-tests.result == 'success' || needs.unit-tests.result == 'skipped')) needs: [lint, unit-tests] name: "Publish to Quay" runs-on: ubuntu-latest @@ -126,7 +128,9 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-to-dockerhub: - if: ${{ inputs.publish-to-docker == 'true' }} + if: | + always() && + (${{ inputs.publish-to-docker == 'true' }} && (needs.unit-tests.result == 'success' || needs.unit-tests.result == 'skipped')) needs: [lint, unit-tests] name: "Publish to Dockerhub" runs-on: ubuntu-latest @@ -159,7 +163,9 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-git-tag: - if: ${{ inputs.publish-git-tag == 'true' }} + if: | + always() && + (${{ inputs.publish-git-tag == 'true' }} && (needs.unit-tests.result == 'success' || needs.unit-tests.result == 'skipped')) needs: [lint, unit-tests] name: "Publish Git Tag" runs-on: ubuntu-latest @@ -190,7 +196,9 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-libs: - if: ${{ inputs.publish-to-npm == 'true' }} + if: | + always() && + (${{ inputs.publish-to-npm == 'true' }} && (needs.unit-tests.result == 'success' || needs.unit-tests.result == 'skipped')) needs: [lint, unit-tests] name: "Publish libs to NPM and GitHub registry" runs-on: ubuntu-latest