From 6bb813c41ffd43e3159126fef0aff371fae16ea2 Mon Sep 17 00:00:00 2001 From: Ivan Pomykacz Date: Wed, 20 Mar 2024 10:13:19 +0200 Subject: [PATCH] chore: beta relase pipeline --- .gitattributes | 2 + .github/workflows/build.yml | 28 ------ .github/workflows/release-beta.yml | 145 +++++++++++++++++++++++++++++ .github/workflows/release.yml | 35 ------- .github/workflows/upgrade-beta.yml | 90 ++++++++++++++++++ .gitignore | 2 + .mergify.yml | 2 - .projen/files.json | 2 + .projen/tasks.json | 41 +++++--- .projenrc.js | 17 +++- package.json | 6 +- 11 files changed, 282 insertions(+), 88 deletions(-) create mode 100644 .github/workflows/release-beta.yml create mode 100644 .github/workflows/upgrade-beta.yml diff --git a/.gitattributes b/.gitattributes index 0d6aaef..ccf25b9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,7 +6,9 @@ /.github/pull_request_template.md linguist-generated /.github/workflows/build.yml linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated +/.github/workflows/release-beta.yml linguist-generated /.github/workflows/release.yml linguist-generated +/.github/workflows/upgrade-beta.yml linguist-generated /.github/workflows/upgrade-main.yml linguist-generated /.gitignore linguist-generated /.mergify.yml linguist-generated diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c15edae..2f68fd2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -106,34 +106,6 @@ jobs: run: cd .repo && npx projen package:js - name: Collect js Artifact run: mv .repo/dist dist - package-python: - needs: build - runs-on: ubuntu-latest - permissions: {} - if: "! needs.build.outputs.self_mutation_happened" - steps: - - uses: actions/setup-node@v3 - with: - node-version: 14.17.6 - - uses: actions/setup-python@v4 - with: - python-version: 3.x - - name: Download build artifacts - uses: actions/download-artifact@v3 - with: - name: build-artifact - path: dist - - name: Restore build artifact permissions - run: cd dist && setfacl --restore=permissions-backup.acl - continue-on-error: true - - name: Prepare Repository - run: mv dist .repo - - name: Install Dependencies - run: cd .repo && npm ci - - name: Create python artifact - run: cd .repo && npx projen package:python - - name: Collect python Artifact - run: mv .repo/dist dist package-go: needs: build runs-on: ubuntu-latest diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml new file mode 100644 index 0000000..4d9c8bb --- /dev/null +++ b/.github/workflows/release-beta.yml @@ -0,0 +1,145 @@ +# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". + +name: release-beta +on: + push: + branches: + - beta + workflow_dispatch: {} +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + latest_commit: ${{ steps.git_remote.outputs.latest_commit }} + env: + CI: "true" + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set git identity + run: |- + git config user.name "github-actions" + git config user.email "github-actions@github.com" + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 14.17.6 + - name: Install dependencies + run: npm ci + - name: release:beta + run: npx projen release:beta + - name: Check for new commits + id: git_remote + run: echo "latest_commit=$(git ls-remote origin -h ${{ github.ref }} | cut -f1)" >> $GITHUB_OUTPUT + - name: Backup artifact permissions + if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} + run: cd dist && getfacl -R . > permissions-backup.acl + continue-on-error: true + - name: Upload artifact + if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} + uses: actions/upload-artifact@v3 + with: + name: build-artifact + path: dist + release_github: + name: Publish to GitHub Releases + needs: release + runs-on: ubuntu-latest + permissions: + contents: write + if: needs.release.outputs.latest_commit == github.sha + steps: + - uses: actions/setup-node@v3 + with: + node-version: 14.17.6 + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifact + path: dist + - name: Restore build artifact permissions + run: cd dist && setfacl --restore=permissions-backup.acl + continue-on-error: true + - name: Prepare Repository + run: mv dist .repo + - name: Collect GitHub Metadata + run: mv .repo/dist dist + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_REF: ${{ github.ref }} + run: errout=$(mktemp); gh release create $(cat dist/releasetag.txt) -R $GITHUB_REPOSITORY -F dist/changelog.md -t $(cat dist/releasetag.txt) --target $GITHUB_REF -p 2> $errout && true; exitcode=$?; if [ $exitcode -ne 0 ] && ! grep -q "Release.tag_name already exists" $errout; then cat $errout; exit $exitcode; fi + release_npm: + name: Publish to npm + needs: release + runs-on: ubuntu-latest + permissions: + contents: read + if: needs.release.outputs.latest_commit == github.sha + steps: + - uses: actions/setup-node@v3 + with: + node-version: 14.17.6 + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifact + path: dist + - name: Restore build artifact permissions + run: cd dist && setfacl --restore=permissions-backup.acl + continue-on-error: true + - name: Prepare Repository + run: mv dist .repo + - name: Install Dependencies + run: cd .repo && npm ci + - name: Create js artifact + run: cd .repo && npx projen package:js + - name: Collect js Artifact + run: mv .repo/dist dist + - name: Release + env: + NPM_DIST_TAG: beta + NPM_REGISTRY: registry.npmjs.org + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx -p publib@latest publib-npm + release_golang: + name: Publish to GitHub Go Module Repository + needs: release + runs-on: ubuntu-latest + permissions: + contents: read + if: needs.release.outputs.latest_commit == github.sha + steps: + - uses: actions/setup-node@v3 + with: + node-version: 14.17.6 + - uses: actions/setup-go@v3 + with: + go-version: ^1.16.0 + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifact + path: dist + - name: Restore build artifact permissions + run: cd dist && setfacl --restore=permissions-backup.acl + continue-on-error: true + - name: Prepare Repository + run: mv dist .repo + - name: Install Dependencies + run: cd .repo && npm ci + - name: Create go artifact + run: cd .repo && npx projen package:go + - name: Collect go Artifact + run: mv .repo/dist dist + - name: Release + env: + GIT_USER_NAME: github-actions + GIT_USER_EMAIL: github-actions@github.com + GITHUB_TOKEN: ${{ secrets.GO_GITHUB_TOKEN }} + run: npx -p publib@latest publib-golang diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4210bfc..383bac3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -107,41 +107,6 @@ jobs: NPM_REGISTRY: registry.npmjs.org NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: npx -p publib@latest publib-npm - release_pypi: - name: Publish to PyPI - needs: release - runs-on: ubuntu-latest - permissions: - contents: read - if: needs.release.outputs.latest_commit == github.sha - steps: - - uses: actions/setup-node@v3 - with: - node-version: 14.17.6 - - uses: actions/setup-python@v4 - with: - python-version: 3.x - - name: Download build artifacts - uses: actions/download-artifact@v3 - with: - name: build-artifact - path: dist - - name: Restore build artifact permissions - run: cd dist && setfacl --restore=permissions-backup.acl - continue-on-error: true - - name: Prepare Repository - run: mv dist .repo - - name: Install Dependencies - run: cd .repo && npm ci - - name: Create python artifact - run: cd .repo && npx projen package:python - - name: Collect python Artifact - run: mv .repo/dist dist - - name: Release - env: - TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - run: npx -p publib@latest publib-pypi release_golang: name: Publish to GitHub Go Module Repository needs: release diff --git a/.github/workflows/upgrade-beta.yml b/.github/workflows/upgrade-beta.yml new file mode 100644 index 0000000..6d1ea13 --- /dev/null +++ b/.github/workflows/upgrade-beta.yml @@ -0,0 +1,90 @@ +# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen". + +name: upgrade-beta +on: + workflow_dispatch: {} + schedule: + - cron: 0 0 * * * +jobs: + upgrade: + name: Upgrade + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + patch_created: ${{ steps.create_patch.outputs.patch_created }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: beta + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 14.17.6 + - name: Install dependencies + run: npm ci + - name: Upgrade dependencies + run: npx projen upgrade + - name: Find mutations + id: create_patch + run: |- + git add . + git diff --staged --patch --exit-code > .repo.patch || echo "patch_created=true" >> $GITHUB_OUTPUT + - name: Upload patch + if: steps.create_patch.outputs.patch_created + uses: actions/upload-artifact@v3 + with: + name: .repo.patch + path: .repo.patch + pr: + name: Create Pull Request + needs: upgrade + runs-on: ubuntu-latest + permissions: + contents: read + if: ${{ needs.upgrade.outputs.patch_created }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: beta + - name: Download patch + uses: actions/download-artifact@v3 + with: + name: .repo.patch + path: ${{ runner.temp }} + - name: Apply patch + run: '[ -s ${{ runner.temp }}/.repo.patch ] && git apply ${{ runner.temp }}/.repo.patch || echo "Empty patch. Skipping."' + - name: Set git identity + run: |- + git config user.name "github-actions" + git config user.email "github-actions@github.com" + - name: Create Pull Request + id: create-pr + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.PROJEN_GITHUB_TOKEN }} + commit-message: |- + chore(deps): upgrade dependencies + + Upgrades project dependencies. See details in [workflow run]. + + [Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + + ------ + + *Automatically created by projen via the "upgrade-beta" workflow* + branch: github-actions/upgrade-beta + title: "chore(deps): upgrade dependencies" + body: |- + Upgrades project dependencies. See details in [workflow run]. + + [Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + + ------ + + *Automatically created by projen via the "upgrade-beta" workflow* + author: github-actions + committer: github-actions + signoff: true diff --git a/.gitignore b/.gitignore index 9fb4a2a..04d32b9 100644 --- a/.gitignore +++ b/.gitignore @@ -44,8 +44,10 @@ junit.xml /dist/changelog.md /dist/version.txt !/.github/workflows/release.yml +!/.github/workflows/release-beta.yml !/.mergify.yml !/.github/workflows/upgrade-main.yml +!/.github/workflows/upgrade-beta.yml !/.github/pull_request_template.md !/test/ !/tsconfig.dev.json diff --git a/.mergify.yml b/.mergify.yml index 67360ca..e75979a 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -7,7 +7,6 @@ queue_rules: - -label~=(do-not-merge) - status-success=build - status-success=package-js - - status-success=package-python - status-success=package-go pull_request_rules: - name: Automatic merge on approval and successful build @@ -25,5 +24,4 @@ pull_request_rules: - -label~=(do-not-merge) - status-success=build - status-success=package-js - - status-success=package-python - status-success=package-go diff --git a/.projen/files.json b/.projen/files.json index 530b106..fa05ca4 100644 --- a/.projen/files.json +++ b/.projen/files.json @@ -5,7 +5,9 @@ ".github/pull_request_template.md", ".github/workflows/build.yml", ".github/workflows/pull-request-lint.yml", + ".github/workflows/release-beta.yml", ".github/workflows/release.yml", + ".github/workflows/upgrade-beta.yml", ".github/workflows/upgrade-main.yml", ".gitignore", ".mergify.yml", diff --git a/.projen/tasks.json b/.projen/tasks.json index d2fc8d4..9f23e4d 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -146,9 +146,6 @@ { "spawn": "package:js" }, - { - "spawn": "package:python" - }, { "spawn": "package:go" } @@ -172,15 +169,6 @@ } ] }, - "package:python": { - "name": "package:python", - "description": "Create python language bindings", - "steps": [ - { - "exec": "jsii-pacmak -v --target python" - } - ] - }, "post-compile": { "name": "post-compile", "description": "Runs after successful compilation", @@ -202,7 +190,34 @@ "name": "release", "description": "Prepare a release from \"main\" branch", "env": { - "RELEASE": "true" + "RELEASE": "true", + "MAJOR": "0" + }, + "steps": [ + { + "exec": "rm -fr dist" + }, + { + "spawn": "bump" + }, + { + "spawn": "build" + }, + { + "spawn": "unbump" + }, + { + "exec": "git diff --ignore-space-at-eol --exit-code" + } + ] + }, + "release:beta": { + "name": "release:beta", + "description": "Prepare a release from \"beta\" branch", + "env": { + "RELEASE": "true", + "MAJOR": "1", + "PRERELEASE": "beta" }, "steps": [ { diff --git a/.projenrc.js b/.projenrc.js index 23cd7e6..de2e20a 100644 --- a/.projenrc.js +++ b/.projenrc.js @@ -13,15 +13,22 @@ const project = new awscdk.AwsCdkConstructLibrary({ description: 'Opinionated CDK Project “Framework”', repositoryUrl: 'https://github.com/alma-cdk/project.git', keywords: ['cdk', 'aws-cdk', 'awscdk', 'aws'], - + majorVersion: 0, + releaseBranches: { + beta: { + majorVersion: 1, + prerelease: 'beta', + npmDistTag: 'beta', + }, + }, // Publish configuration defaultReleaseBranch: 'main', packageManager: javascript.NodePackageManager.NPM, npmAccess: javascript.NpmAccess.PUBLIC, - python: { - distName: 'alma-cdk.project', - module: 'alma_cdk.project', - }, + // python: { + // distName: 'alma-cdk.project', + // module: 'alma_cdk.project', + // }, publishToGo: { moduleName: 'github.com/alma-cdk/project-go', }, diff --git a/package.json b/package.json index 81bd7da..04c8d00 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ "package-all": "npx projen package-all", "package:go": "npx projen package:go", "package:js": "npx projen package:js", - "package:python": "npx projen package:python", "post-compile": "npx projen post-compile", "post-upgrade": "npx projen post-upgrade", "pre-compile": "npx projen pre-compile", "release": "npx projen release", + "release:beta": "npx projen release:beta", "test": "npx projen test", "test:watch": "npx projen test:watch", "unbump": "npx projen unbump", @@ -137,10 +137,6 @@ "jsii": { "outdir": "dist", "targets": { - "python": { - "distName": "alma-cdk.project", - "module": "alma_cdk.project" - }, "go": { "moduleName": "github.com/alma-cdk/project-go" }