diff --git a/.github/workflows/dai-release-backend-publish.yaml b/.github/workflows/dai-release-backend-publish.yaml index dbd3dd4..28de3db 100644 --- a/.github/workflows/dai-release-backend-publish.yaml +++ b/.github/workflows/dai-release-backend-publish.yaml @@ -1,11 +1,28 @@ name: Publish dai-release-backend plugin -on: workflow_dispatch +on: + workflow_dispatch: + inputs: + github-publish: + description: 'Github publish' + required: true + default: false + type: boolean + npm-publish: + description: 'Npm publish' + required: true + default: false + type: boolean jobs: - call-ci-workflow: - name: Run build & test for dai-release-backend plugin - uses: ./.github/workflows/reusable-build.yaml + github-publish: + if: ${{ inputs.github-publish == true }} + uses: ./.github/workflows/github-publish.yaml + with: + plugin-path: ./plugins/dai-release-backend + npm-publish: + if: ${{ inputs.npm-publish == true }} + uses: ./.github/workflows/npm-publish.yaml + secrets: inherit with: plugin-path: ./plugins/dai-release-backend - publish: true diff --git a/.github/workflows/dai-release-backend-push.yaml b/.github/workflows/dai-release-backend-push.yaml index 5ab8565..eaf859f 100644 --- a/.github/workflows/dai-release-backend-push.yaml +++ b/.github/workflows/dai-release-backend-push.yaml @@ -1,18 +1,21 @@ name: Push to main on dai-release-backend plugin -on: - push: - branches: [ "main" ] - paths-ignore: - # Ignore changes to READMEs and other Markdown. - - 'plugins/dai-release-backend/**/README*' - - 'plugins/dai-release-backend/**/*.md' - - 'plugins/dai-release/**' - - 'plugins/dai-release-common/**' +on: workflow_call jobs: call-ci-workflow: name: Run build & test for dai-release-backend plugin uses: ./.github/workflows/reusable-build.yaml with: - plugin-path: ./plugins/dai-release-backend \ No newline at end of file + plugin-path: ./plugins/dai-release-backend + version-tag: + uses: ./.github/workflows/version.yaml + needs: [ call-ci-workflow ] + with: + plugin-path: ./plugins/dai-release-backend + plugin: dai-release-backend + github-publish: + needs: [ call-ci-workflow, version-tag ] + uses: ./.github/workflows/github-publish.yaml + with: + plugin-path: ./plugins/dai-release-backend diff --git a/.github/workflows/dai-release-common-publish.yaml b/.github/workflows/dai-release-common-publish.yaml index dbc014d..e51b10e 100644 --- a/.github/workflows/dai-release-common-publish.yaml +++ b/.github/workflows/dai-release-common-publish.yaml @@ -1,11 +1,29 @@ name: Publish dai-release-common plugin -on: workflow_dispatch +on: + workflow_dispatch: + inputs: + github-publish: + description: 'Github publish' + required: true + default: false + type: boolean + npm-publish: + description: 'Npm publish' + required: true + default: false + type: boolean jobs: - call-ci-workflow: - name: Run build & test for dai-release-common plugin - uses: ./.github/workflows/reusable-build.yaml + github-publish: + if: ${{ inputs.github-publish == true }} + uses: ./.github/workflows/github-publish.yaml with: plugin-path: ./plugins/dai-release-common - publish: true + npm-publish: + if: ${{ inputs.npm-publish == true }} + uses: ./.github/workflows/npm-publish.yaml + secrets: inherit + with: + plugin-path: ./plugins/dai-release-common + diff --git a/.github/workflows/dai-release-common-push.yaml b/.github/workflows/dai-release-common-push.yaml index 4cd4d5c..97b227f 100644 --- a/.github/workflows/dai-release-common-push.yaml +++ b/.github/workflows/dai-release-common-push.yaml @@ -2,17 +2,70 @@ name: Push to main on dai-release-common plugin on: push: - branches: [ "main" ] - paths-ignore: - # Ignore changes to READMEs and other Markdown. - - 'plugins/dai-release-common/**/README*' - - 'plugins/dai-release-common/**/*.md' - - 'plugins/dai-release/**' - - 'plugins/dai-release-backend/**' + branches: [ "main" ] # need to map it to main branch jobs: + changes: + runs-on: ubuntu-latest + outputs: + common: ${{ steps.changes.outputs.common }} + backend: ${{ steps.changes.outputs.backend }} + frontend: ${{ steps.changes.outputs.frontend }} + steps: + - uses: actions/checkout@v3 + - uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + common: + - 'plugins/dai-release-common/**' + backend: + - 'plugins/dai-release-backend/**' + frontend: + - 'plugins/dai-release/**' + base: ${{ github.ref_name }} call-ci-workflow: + needs: changes + if: ${{ needs.changes.outputs.common == 'true' }} name: Run build & test for dai-release-common plugin uses: ./.github/workflows/reusable-build.yaml with: - plugin-path: ./plugins/dai-release-common \ No newline at end of file + plugin-path: ./plugins/dai-release-common + version-tag: + uses: ./.github/workflows/version.yaml + needs: [ call-ci-workflow ] + with: + plugin-path: ./plugins/dai-release-common + plugin: dai-release-common + github-publish: + needs: [ call-ci-workflow, version-tag ] + uses: ./.github/workflows/github-publish.yaml + with: + plugin-path: ./plugins/dai-release-common + update-dependencies: + needs: [ call-ci-workflow, version-tag, github-publish ] + uses: ./.github/workflows/update-dependency.yaml + + frontend-ci-workflow: + needs: changes + if: ${{ needs.changes.outputs.frontend == 'true' && needs.changes.outputs.common == 'false'}} + name: Run dai-release plugin without dai-release-common changes. + uses: ./.github/workflows/dai-release-push.yaml + + frontend-common-ci-workflow: + needs: [changes, update-dependencies] + if: ${{ needs.changes.outputs.frontend == 'true' && needs.changes.outputs.common == 'true' }} + name: Run dai-release plugin with dai-release-common changes. + uses: ./.github/workflows/dai-release-push.yaml + + backend-ci-workflow: + needs: changes + if: ${{ needs.changes.outputs.backend == 'true' && needs.changes.outputs.common == 'false'}} + name: Run dai-release-backend plugin without dai-release-common changes. + uses: ./.github/workflows/dai-release-backend-push.yaml + + backend-common-ci-workflow: + needs: [changes, update-dependencies] + if: ${{ needs.changes.outputs.backend == 'true' && needs.changes.outputs.common == 'true' }} + name: Run dai-release-backend plugin with dai-release-common changes. + uses: ./.github/workflows/dai-release-backend-push.yaml diff --git a/.github/workflows/dai-release-publish.yaml b/.github/workflows/dai-release-publish.yaml index 870b621..0f10d2f 100644 --- a/.github/workflows/dai-release-publish.yaml +++ b/.github/workflows/dai-release-publish.yaml @@ -1,11 +1,28 @@ name: Publish dai-release plugin -on: workflow_dispatch +on: + workflow_dispatch: + inputs: + github-publish: + description: 'Github publish' + required: true + default: false + type: boolean + npm-publish: + description: 'Npm publish' + required: true + default: false + type: boolean jobs: - call-ci-workflow: - name: Run build & test for dai-release plugin - uses: ./.github/workflows/reusable-build.yaml + github-publish: + if: ${{ inputs.github-publish == true }} + uses: ./.github/workflows/github-publish.yaml + with: + plugin-path: ./plugins/dai-release + npm-publish: + if: ${{ inputs.npm-publish == true }} + uses: ./.github/workflows/npm-publish.yaml + secrets: inherit with: plugin-path: ./plugins/dai-release - publish: true diff --git a/.github/workflows/dai-release-push.yaml b/.github/workflows/dai-release-push.yaml index addda57..c5429ab 100644 --- a/.github/workflows/dai-release-push.yaml +++ b/.github/workflows/dai-release-push.yaml @@ -1,18 +1,21 @@ name: Push to main on dai-release plugin -on: - push: - branches: [ "main" ] - paths-ignore: - # Ignore changes to READMEs and other Markdown. - - 'plugins/dai-release/**/README*' - - 'plugins/dai-release/**/*.md' - - 'plugins/dai-release-backend/**' - - 'plugins/dai-release-common/**' +on: workflow_call jobs: call-ci-workflow: name: Run build & test for dai-release plugin uses: ./.github/workflows/reusable-build.yaml with: - plugin-path: ./plugins/dai-release \ No newline at end of file + plugin-path: ./plugins/dai-release + version-tag: + uses: ./.github/workflows/version.yaml + needs: [ call-ci-workflow ] + with: + plugin-path: ./plugins/dai-release + plugin: dai-release + github-publish: + needs: [ call-ci-workflow, version-tag ] + uses: ./.github/workflows/github-publish.yaml + with: + plugin-path: ./plugins/dai-release diff --git a/.github/workflows/github-publish.yaml b/.github/workflows/github-publish.yaml new file mode 100644 index 0000000..d437d06 --- /dev/null +++ b/.github/workflows/github-publish.yaml @@ -0,0 +1,42 @@ +name: Github publish + +on: + workflow_call: + inputs: + plugin-path: + required: true + type: string + +jobs: + github-publish: + name: Publish Latest to Github registry + runs-on: ubuntu-latest + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref_name }} # need to map it to main branch + - name: Use Node.js + uses: actions/setup-node@v3 + with: + always-auth: true + node-version: '18.x' + registry-url: 'https://npm.pkg.github.com' + - name: Install dependencies + working-directory: ${{ inputs.plugin-path }} + run: yarn install + - name: Run tsc + working-directory: ${{ inputs.plugin-path }} + run: yarn tsc + - name: Build + working-directory: ${{ inputs.plugin-path }} + run: yarn build + - name: Run tests + working-directory: ${{ inputs.plugin-path }} + run: yarn test + - name: Publish to registry + working-directory: ${{ inputs.plugin-path }} + run: yarn publish \ No newline at end of file diff --git a/.github/workflows/npm-publish.yaml b/.github/workflows/npm-publish.yaml new file mode 100644 index 0000000..1b56ab9 --- /dev/null +++ b/.github/workflows/npm-publish.yaml @@ -0,0 +1,43 @@ +name: NPM publish + +on: + workflow_call: + inputs: + plugin-path: + required: true + type: string + +jobs: + npm-publish: + name: Publish Latest to NPM + runs-on: ubuntu-latest + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # necessary to get newly created tag above + ref: ${{ github.ref_name }} + - name: Use Node.js + uses: actions/setup-node@v3 + with: + always-auth: true + node-version: '18.x' + registry-url: 'https://registry.npmjs.org/' + scope: '@digital-ai' + - name: Install dependencies + working-directory: ${{ inputs.plugin-path }} + run: yarn install + - name: Run tsc + working-directory: ${{ inputs.plugin-path }} + run: yarn tsc + - name: Build + working-directory: ${{ inputs.plugin-path }} + run: yarn build + - name: Run tests + working-directory: ${{ inputs.plugin-path }} + run: yarn test + - name: Publish to registry + working-directory: ${{ inputs.plugin-path }} + run: yarn publish --access public diff --git a/.github/workflows/pr_template.md b/.github/workflows/pr_template.md new file mode 100644 index 0000000..e5a619b --- /dev/null +++ b/.github/workflows/pr_template.md @@ -0,0 +1,38 @@ +## Release Checklist + +- All steps below must be completed prior to merging. + +## Author Checklist + +### Required + +- [ ] PR title should follows correct format. + - MAJOR Release is used when there are breaking changes involved + - MINOR Release is used when enhancements are introduced + - PATCH Release is used for defects, security, tech chores, etc. + - Note: + - Based on the commit messages, increment the version from the latest release. + - Push the bumped npm version in package.json back into the repo. + - Push a tag for the new version back into the repo. + - [For more details on versioning](https://github.com/phips28/gh-action-bump-version/blob/master/README.md) +- [ ] Checklist of **changes made** added to PR description +- [ ] Related issue(s) linked to PR + + +## Reviewer Checklist + +- [ ] Author checklist has been reviewed? +- [ ] All acceptance criteria has been met from linked issue +- [ ] Run code locally and verify all changes + + + + + + + +## Related Issue(s) + +Resolves #XXXX +Story-###### +Defect-###### \ No newline at end of file diff --git a/.github/workflows/reusable-build.yaml b/.github/workflows/reusable-build.yaml index 1951cba..f66d974 100644 --- a/.github/workflows/reusable-build.yaml +++ b/.github/workflows/reusable-build.yaml @@ -6,9 +6,6 @@ on: plugin-path: required: true type: string - publish: - required: false - type: boolean jobs: build_job: @@ -16,26 +13,25 @@ jobs: runs-on: ubuntu-latest env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '18.x' - registry-url: 'https://npm.pkg.github.com' - - name: Install dependencies - working-directory: ${{ inputs.plugin-path }} - run: yarn install - - name: Run tsc - working-directory: ${{ inputs.plugin-path }} - run: yarn tsc - - name: Build - working-directory: ${{ inputs.plugin-path }} - run: yarn build - - name: Run tests - working-directory: ${{ inputs.plugin-path }} - run: yarn test - - name: Publish to registry - if: ${{ inputs.publish }} - working-directory: ${{ inputs.plugin-path }} - run: yarn publish + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref_name }} # need to map it to main branch + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.x' + registry-url: 'https://npm.pkg.github.com' + - name: Install dependencies + working-directory: ${{ inputs.plugin-path }} + run: yarn install + - name: Run tsc + working-directory: ${{ inputs.plugin-path }} + run: yarn tsc + - name: Build + working-directory: ${{ inputs.plugin-path }} + run: yarn build + - name: Run tests + working-directory: ${{ inputs.plugin-path }} + run: yarn test diff --git a/.github/workflows/update-dependency.yaml b/.github/workflows/update-dependency.yaml new file mode 100644 index 0000000..68da25a --- /dev/null +++ b/.github/workflows/update-dependency.yaml @@ -0,0 +1,34 @@ +name: Update-Dependency of dai-release-common plugin + +on: workflow_call + +jobs: + update-dependency: + name: Update Latest version of dai-release-common. + runs-on: ubuntu-latest + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref_name }} + - name: Update Package of Other Module + run: | + # Extract the version of the package from the output of the previous jobs + PACKAGE_VERSION=$(grep '"version"' ./plugins/dai-release-common/package.json | awk -F '"' '{print $4}') + echo $PACKAGE_VERSION + echo "Updating package.json: ./plugins/dai-release/package.json" + sed -i 's/"@digital-ai\/plugin-dai-release-common": ".*"/"@digital-ai\/plugin-dai-release-common": "'"$PACKAGE_VERSION"'"/' ./plugins/dai-release/package.json + echo "Updating package.json: ./plugins/dai-release-backend/package.json" + sed -i 's/"@digital-ai\/plugin-dai-release-common": ".*"/"@digital-ai\/plugin-dai-release-common": "'"$PACKAGE_VERSION"'"/' ./plugins/dai-release-backend/package.json + echo "Done" + - name: Commit and Push Changes + run: | + git pull origin ${{ github.ref_name }} + git config user.name "GitHub Actions" + git config user.email "<>" + git add . + git commit -m "chore: update dependencies" + git push origin ${{ github.ref_name }} diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml new file mode 100644 index 0000000..ff36fa6 --- /dev/null +++ b/.github/workflows/version.yaml @@ -0,0 +1,66 @@ +name: Versioning and tag/release creation + +on: + workflow_call: + inputs: + plugin-path: + required: true + type: string + plugin: + required: true + type: string + +jobs: + bump-version: + name: Bump Version & Create GitHub Tag + runs-on: ubuntu-latest + outputs: + new-version: ${{ steps.version-bump.outputs.newTag }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # necessary to get newly created tag above + ref: ${{ github.ref_name }} # need to map it to main branch + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 18.19.0 + - name: Automated Version Bump + id: version-bump + uses: phips28/gh-action-bump-version@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PACKAGEJSON_DIR: ${{ inputs.plugin-path }} + with: + commit-message: "CI: bumps version to {{version}} [skip ci]" + tag-prefix: '${{ inputs.plugin }}/v' + major-wording: 'MAJOR' + minor-wording: 'MINOR' + preid: 'alpha' + target-branch: ${{ github.ref_name }} # need to map it to main branch + + create-release: + name: Create GitHub Release + runs-on: ubuntu-latest + needs: [ bump-version ] + if: needs.bump-version.outputs.new-version != '' + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # necessary to get newly created tag above + ref: ${{ github.ref_name }} # need to map it to main branch + - name: New Version + working-directory: ${{ inputs.plugin-path }} + env: + NEW_VERSION: ${{ steps.bump-version.outputs.new-version }} + run: echo "new version $NEW_VERSION" + + - name: Create tag and release + uses: ncipollo/release-action@v1 + env: + PACKAGEJSON_DIR: ${{ inputs.plugin-path }} + with: + name: ${{ needs.bump-version.outputs.new-version }} + tag: ${{ needs.bump-version.outputs.new-version }} \ No newline at end of file diff --git a/plugins/dai-release-backend/package.json b/plugins/dai-release-backend/package.json index ced836e..85df830 100644 --- a/plugins/dai-release-backend/package.json +++ b/plugins/dai-release-backend/package.json @@ -1,6 +1,6 @@ { "name": "@digital-ai/plugin-dai-release-backend", - "version": "0.1.0", + "version": "0.0.1", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", @@ -34,7 +34,7 @@ "@backstage/plugin-permission-common": "^0.7.12", "@backstage/plugin-permission-node": "^0.7.24", "@digital-ai/plugin-dai-deploy-common": "^0.1.0", - "@digital-ai/plugin-dai-release-common": "^0.1.0", + "@digital-ai/plugin-dai-release-common": "0.0.1", "@types/express": "*", "express": "^4.17.1", "express-promise-router": "^4.1.0", diff --git a/plugins/dai-release-common/package.json b/plugins/dai-release-common/package.json index 6389c9c..9e59ec0 100644 --- a/plugins/dai-release-common/package.json +++ b/plugins/dai-release-common/package.json @@ -1,7 +1,7 @@ { "name": "@digital-ai/plugin-dai-release-common", "description": "Common functionalities for the dai-release plugin", - "version": "0.1.0", + "version": "0.0.1", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", diff --git a/plugins/dai-release/package.json b/plugins/dai-release/package.json index e5aca7d..64ba314 100644 --- a/plugins/dai-release/package.json +++ b/plugins/dai-release/package.json @@ -1,6 +1,6 @@ { "name": "@digital-ai/plugin-dai-release", - "version": "0.1.0", + "version": "0.0.1", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", @@ -31,7 +31,7 @@ "@backstage/errors": "^1.2.3", "@backstage/plugin-permission-react": "^0.4.20", "@backstage/theme": "^0.4.2", - "@digital-ai/plugin-dai-release-common": "^0.1.0", + "@digital-ai/plugin-dai-release-common": "0.0.1", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.0", "@material-ui/core": "^4.12.2",