From 41273877314d59de0a95e0a0655289a106ccb6a1 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 15 Nov 2022 16:33:39 -0500 Subject: [PATCH] refactor(ci): release process runs in parallel (#26269) --- .github/workflows/actions/release/action.yml | 43 +++ .github/workflows/release.yml | 260 +++++++++++++++---- angular/package.json | 4 - core/package.json | 1 - docs/package.json | 2 +- packages/angular-server/package.json | 1 - packages/react-router/package.json | 1 - packages/react/package.json | 1 - packages/vue-router/package.json | 1 - packages/vue/package.json | 1 - 10 files changed, 258 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/actions/release/action.yml diff --git a/.github/workflows/actions/release/action.yml b/.github/workflows/actions/release/action.yml new file mode 100644 index 0000000000..a03342a015 --- /dev/null +++ b/.github/workflows/actions/release/action.yml @@ -0,0 +1,43 @@ +name: 'Release' +description: 'Releases a package' +inputs: + scope: + description: 'The package to release. Must match a package specified in lerna.json.' + version: + description: 'The type of version to release.' + tag: + description: 'The tag to publish to on NPM.' + working-directory: + description: 'The directory of the package.' + folder: + default: './' + description: 'A folder containing a package.json file.' + token: + description: 'The NPM authentication token required to publish.' +runs: + using: 'composite' + steps: + - uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: Install Dependencies + run: lerna bootstrap --scope ${{ inputs.scope }} --ignore-scripts -- --legacy-peer-deps + shell: bash + working-directory: ${{ inputs.working-directory }} + - name: Update Version + run: npm version ${{ inputs.version }} + shell: bash + working-directory: ${{ inputs.working-directory }} + - name: Run Build + run: npm run build + shell: bash + working-directory: ${{ inputs.working-directory }} + - name: Prepare NPM Token + run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc + shell: bash + env: + NPM_TOKEN: ${{ inputs.token }} + - name: Publish to NPM + run: npm publish ${{ inputs.folder }} --tag ${{ inputs.tag }} --git-tag-version false + shell: bash + working-directory: ${{ inputs.working-directory }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 75b4d4902d..77fea3d9c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,52 +21,221 @@ on: - v4-lts jobs: - build-ionic: + release-core: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/workflows/actions/release + with: + scope: '@ionic/core' + tag: ${{ inputs.tag }} + version: ${{ inputs.version }} + working-directory: 'core' + token: ${{ secrets.NPM_TOKEN }} + - name: Cache Built @ionic/core + uses: ./.github/workflows/actions/upload-archive + with: + name: ionic-core + output: core/CoreBuild.zip + paths: core/dist core/components core/css core/hydrate core/loader core/src/components.d.ts + - name: Cache Built @ionic/docs + uses: ./.github/workflows/actions/upload-archive + with: + name: ionic-docs + output: docs/DocsBuild.zip + paths: docs/core.json docs/core.d.ts + + release-docs: + needs: [release-core] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Restore @ionic/docs built cache + uses: ./.github/workflows/actions/download-archive + with: + name: ionic-docs + path: ./docs + filename: DocsBuild.zip + - uses: ./.github/workflows/actions/release + with: + scope: '@ionic/docs' + tag: ${{ inputs.tag }} + version: ${{ inputs.version }} + working-directory: 'docs' + token: ${{ secrets.NPM_TOKEN }} + + release-angular: + needs: [release-core] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Restore @ionic/core built cache + uses: ./.github/workflows/actions/download-archive + with: + name: ionic-core + path: ./core + filename: CoreBuild.zip + - uses: ./.github/workflows/actions/release + with: + scope: '@ionic/angular' + tag: ${{ inputs.tag }} + version: ${{ inputs.version }} + working-directory: 'angular' + folder: './dist' + token: ${{ secrets.NPM_TOKEN }} + - name: Cache Built @ionic/angular + uses: ./.github/workflows/actions/upload-archive + with: + name: ionic-angular + output: ./angular/AngularBuild.zip + paths: ./angular/dist + + release-react: + needs: [release-core] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Restore @ionic/core built cache + uses: ./.github/workflows/actions/download-archive + with: + name: ionic-core + path: ./core + filename: CoreBuild.zip + - uses: ./.github/workflows/actions/release + with: + scope: '@ionic/react' + tag: ${{ inputs.tag }} + version: ${{ inputs.version }} + working-directory: 'packages/react' + token: ${{ secrets.NPM_TOKEN }} + - name: Cache Built @ionic/react + uses: ./.github/workflows/actions/upload-archive + with: + name: ionic-react + output: packages/react/ReactBuild.zip + paths: packages/react/dist packages/react/css + + release-vue: + needs: [release-core] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Restore @ionic/core built cache + uses: ./.github/workflows/actions/download-archive + with: + name: ionic-core + path: ./core + filename: CoreBuild.zip + - uses: ./.github/workflows/actions/release + with: + scope: '@ionic/vue' + tag: ${{ inputs.tag }} + version: ${{ inputs.version }} + working-directory: 'packages/vue' + token: ${{ secrets.NPM_TOKEN }} + - name: Cache Built @ionic/vue + uses: ./.github/workflows/actions/upload-archive + with: + name: ionic-vue + output: packages/vue/VueBuild.zip + paths: packages/vue/dist packages/vue/css + + release-angular-server: + needs: [release-angular] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Restore @ionic/angular built cache + uses: ./.github/workflows/actions/download-archive + with: + name: ionic-angular + path: ./angular + filename: AngularBuild.zip + - uses: ./.github/workflows/actions/release + with: + scope: '@ionic/angular-server' + tag: ${{ inputs.tag }} + version: ${{ inputs.version }} + working-directory: 'packages/angular-server' + folder: './dist' + token: ${{ secrets.NPM_TOKEN }} + + release-react-router: + needs: [release-react] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Restore @ionic/react built cache + uses: ./.github/workflows/actions/download-archive + with: + name: ionic-react + path: ./packages/react + filename: ReactBuild.zip + - uses: ./.github/workflows/actions/release + with: + scope: '@ionic/react-router' + tag: ${{ inputs.tag }} + version: ${{ inputs.version }} + working-directory: 'packages/react-router' + token: ${{ secrets.NPM_TOKEN }} + + release-vue-router: + needs: [release-vue] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Restore @ionic/vue built cache + uses: ./.github/workflows/actions/download-archive + with: + name: ionic-vue + path: ./packages/vue + filename: VueBuild.zip + - uses: ./.github/workflows/actions/release + with: + scope: '@ionic/vue-router' + tag: ${{ inputs.tag }} + version: ${{ inputs.version }} + working-directory: 'packages/vue-router' + token: ${{ secrets.NPM_TOKEN }} + + finalize-release: + needs: [release-react-router, release-angular-server, release-vue-router] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.IONITRON_TOKEN }} + fetch-depth: 0 + - name: Configure Identity + # Commits from github-actions do not + # trigger other GitHub Actions. As a result, + # we publish releases from Ionitron instead + # so actions run when merging the release branch + # back into main. + run: | + git config user.name ionitron + git config user.email hi@ionicframework.com + shell: bash + - name: Create GitHub Release + run: lerna version ${{ inputs.version }} --yes --force-publish='*' --conventional-commits --create-release github + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + # Lerna does not automatically bump versions + # of Ionic dependencies that have changed, + # so we do that here. + - name: Bump Package Lock + run: | + lerna exec "npm install --package-lock-only --legacy-peer-deps" + git add . + git commit -m "chore(): update package lock files" + git push + shell: bash + + purge-cdn-cache: + needs: [release-react-router, release-angular-server, release-vue-router] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - token: ${{ secrets.IONITRON_TOKEN }} - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Configure Identity - # Commits from github-actions do not - # trigger other GitHub Actions. As a result, - # we publish releases from Ionitron instead - # so actions run when merging the release branch - # back into main. - run: | - git config user.name ionitron - git config user.email hi@ionicframework.com - shell: bash - - name: Install Dependencies - run: npm ci --no-package-lock && lerna bootstrap --ignore-scripts -- --legacy-peer-deps - shell: bash - - name: Prepare NPM Token - run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc - shell: bash - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Release - run: | - HUSKY_SKIP_HOOKS=1 lerna publish $(echo "${{ github.event.inputs.version }}") --no-verify-access --yes --force-publish='*' --dist-tag $(echo "${{ github.event.inputs.tag }}") --conventional-commits --create-release github - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - shell: bash - # Lerna does not automatically bump versions - # of Ionic dependencies that have changed, - # so we do that here. - - name: Bump Package Lock - run: | - lerna exec "npm install --package-lock-only --legacy-peer-deps" - git add . - git commit -m "chore(): update package lock files" - git push - # Purge the JSDeliver CDN cache so - # component playgrounds always load - # the latest version of Ionic. - name: Purge JSDelivr Cache run: | curl -X POST \ @@ -80,5 +249,4 @@ jobs: "/npm/@ionic/core@6/css/ionic.bundle.css", "/npm/@ionic/core@latest/css/ionic.bundle.css" ]}' - - + shell: bash diff --git a/angular/package.json b/angular/package.json index 1c129a6e8c..d84ed492ff 100644 --- a/angular/package.json +++ b/angular/package.json @@ -22,12 +22,8 @@ "bugs": { "url": "https://github.com/ionic-team/ionic/issues" }, - "publishConfig": { - "directory": "dist" - }, "homepage": "https://ionicframework.com/", "scripts": { - "prepublishOnly": "npm run build", "build": "npm run clean && npm run build.ng && npm run build.core && npm run clean-generated", "build.core": "node scripts/build-core.js", "build.link": "npm run build && node scripts/link-copy.js", diff --git a/core/package.json b/core/package.json index 0c2bd47c04..80de50ac5b 100644 --- a/core/package.json +++ b/core/package.json @@ -75,7 +75,6 @@ "typescript": "^4.0.5" }, "scripts": { - "prepublishOnly": "npm run build", "build": "npm run clean && npm run build.css && stencil build --es5 --docs-json dist/docs.json && npm run cdnloader", "build.css": "npm run css.sass && npm run css.minify", "build.debug": "npm run clean && stencil build --debug", diff --git a/docs/package.json b/docs/package.json index df8274a2f9..093fbe928b 100644 --- a/docs/package.json +++ b/docs/package.json @@ -18,7 +18,7 @@ "url": "https://github.com/ionic-team/ionic-docs/issues" }, "scripts": { - "prepublishOnly": "echo noop" + "build": "echo noop" }, "homepage": "https://ionicframework.com/docs" } diff --git a/packages/angular-server/package.json b/packages/angular-server/package.json index 03c0dd913f..60013ea596 100644 --- a/packages/angular-server/package.json +++ b/packages/angular-server/package.json @@ -24,7 +24,6 @@ }, "homepage": "https://ionicframework.com/", "scripts": { - "prepublishOnly": "npm run build.prod", "test": "echo 'angular no tests yet'", "build": "ng-packagr -p package.json -c tsconfig.json", "build.prod": "npm run clean && npm run build", diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 28ebdb16a2..ddda3c6da1 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -20,7 +20,6 @@ "url": "https://github.com/ionic-team/ionic.git" }, "scripts": { - "prepublishOnly": "npm run build", "build": "npm run clean && npm run compile", "clean": "rimraf dist dist-transpiled", "compile": "npm run tsc && rollup -c", diff --git a/packages/react/package.json b/packages/react/package.json index 4f5cc00f71..678210dba1 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -20,7 +20,6 @@ "url": "https://github.com/ionic-team/ionic.git" }, "scripts": { - "prepublishOnly": "npm run build", "build": "npm run clean && npm run copy && npm run compile", "clean": "rimraf dist && rimraf dist-transpiled && rimraf routing", "compile": "npm run tsc && rollup -c", diff --git a/packages/vue-router/package.json b/packages/vue-router/package.json index 194269a6c9..7db8ca39ed 100644 --- a/packages/vue-router/package.json +++ b/packages/vue-router/package.json @@ -3,7 +3,6 @@ "version": "6.3.6", "description": "Vue Router integration for @ionic/vue", "scripts": { - "prepublishOnly": "npm run build", "test.spec": "jest", "lint": "echo add linter", "bundle": "rollup --config rollup.config.js", diff --git a/packages/vue/package.json b/packages/vue/package.json index cf0fa78eed..6ff89d409f 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -3,7 +3,6 @@ "version": "6.3.6", "description": "Vue specific wrapper for @ionic/core", "scripts": { - "prepublishOnly": "npm run build", "lint": "echo add linter", "lint.fix": "npm run lint -- --fix", "test": "jest",