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..658ef98f7f 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,56 @@ 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@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: + 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@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-docker-registry: + 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 steps: @@ -34,6 +110,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 +128,10 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-to-dockerhub: + 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 steps: @@ -63,6 +145,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 +163,10 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-git-tag: + 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 steps: @@ -91,8 +179,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 +196,10 @@ jobs: dry-run: ${{ inputs.dry-run-release }} publish-libs: + 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 permissions: @@ -122,6 +217,8 @@ jobs: cache: 'npm' - uses: ./.github/actions/setup + with: + npm_tag: ${{ inputs.npm-tag }} - name: publish uses: ./.github/actions/publish-libs