diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index e708b71558..508a69e0d6 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -14,6 +14,7 @@ env: IMAGE: ${{ secrets.DOCKER_USERNAME }}/p5.js-web-editor-staging jobs: push_to_registry: + if: ${{ github.event.workflow_run.conclusion == 'success' }} environment: staging name: Push Docker image to Docker Hub runs-on: ubuntu-latest diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 08e8f4ffe5..51450c355b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,11 +1,8 @@ name: Deploy to production on: - workflow_run: - workflows: ["Test"] - branches: - - release + release: types: - - completed + - published env: PROJECT_ID: ${{ secrets.GKE_PROJECT }} GKE_CLUSTER: p5-gke-cluster @@ -21,7 +18,7 @@ jobs: - name: Check out the repo uses: actions/checkout@v3 with: - ref: release + ref: ${{ github.event.release.tag_name }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 with: diff --git a/.github/workflows/release-reminder.yml b/.github/workflows/release-reminder.yml new file mode 100644 index 0000000000..8781667963 --- /dev/null +++ b/.github/workflows/release-reminder.yml @@ -0,0 +1,32 @@ +name: Weekly release reminder + +on: + # Tuesdays 15:30 UTC + schedule: + - cron: "30 15 * * 2" + workflow_dispatch: {} + +permissions: + issues: write + +jobs: + remind: + runs-on: ubuntu-latest + steps: + - name: Open release reminder issue + uses: actions/github-script@v7 + with: + script: | + await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: `Weekly release - ${new Date().toISOString().slice(0, 10)}`, + body: [ + "1. Decide on any remaining PRs to merge into `develop`", + "2. Review what's merged into `develop` since the last release.", + "3. Decide the version bump (patch/minor/major).", + "4. Run the [Create a release](../actions/workflows/release.yml) workflow with that version.", + "", + "No release needed this week? Just close this issue." + ].join("\n") + }); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..182db29364 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,95 @@ +name: Create a release + +on: + workflow_dispatch: + inputs: + newversion: + description: > + Version to release. Accepts an explicit semver (e.g. 2.22.0) or an + npm version keyword (patch, minor, major, prepatch, preminor, + premajor, prerelease). See https://docs.npmjs.com/cli/version + required: true + type: string + +permissions: + contents: write + +jobs: + verify: + runs-on: ubuntu-latest + steps: + - name: Check out develop + uses: actions/checkout@v4 + with: + ref: develop + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '18.20.x' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm run test:ci + + # future: deploy to staging (+stop deploying to staging upon merges to develop) + e2e test pointed at staging + + release: + needs: verify + runs-on: ubuntu-latest + # Requires a maintainer to approve in the Actions UI before this job runs. + # Configure required reviewers under Settings > Environments > release-approval. + environment: release-approval + steps: + - name: Check out develop + uses: actions/checkout@v4 + with: + ref: develop + + - name: Fetch release branch + run: git fetch origin release:release + + - name: Configure git identity + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Create cut release branch + run: git checkout -b "release-${{ inputs.newversion }}" + + - name: Bump version + id: bump + run: | + NEW_VERSION=$(npm version "${{ inputs.newversion }}" -m "v%s") + echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" + + - name: Merge into release + run: | + git checkout release + git pull origin release + git merge --no-ff "release-${{ inputs.newversion }}" -m "Merge release-${{ inputs.newversion }} into release" + git push origin release + git push origin --tags + + - name: Merge back into develop + run: | + git checkout develop + git pull origin develop + git merge --no-ff "release-${{ inputs.newversion }}" -m "Merge release-${{ inputs.newversion }} into develop" + git push origin develop + + - name: Push cut release branch + run: git push origin "release-${{ inputs.newversion }}" + + - name: Draft GitHub release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create "${{ steps.bump.outputs.version }}" \ + --target release \ + --title "${{ steps.bump.outputs.version }}" \ + --generate-notes \ + --draft diff --git a/contributor_docs/release.md b/contributor_docs/release.md index d2e17f5501..f2619be02d 100644 --- a/contributor_docs/release.md +++ b/contributor_docs/release.md @@ -3,13 +3,39 @@ A guide for deploying a release to the p5.js Editor production environment. ## Background + This project's release guide is based on: -* [git-flow](https://nvie.com/posts/a-successful-git-branching-model/) -* [Semantic Versioning (semver)](https://semver.org/) -* [npm-version](https://docs.npmjs.com/cli/version) -* [Let's stop saying Master/Slave](https://medium.com/@mikebroberts/let-s-stop-saying-master-slave-10f1d1bf34df) -## Steps +- [git-flow](https://nvie.com/posts/a-successful-git-branching-model/) +- [Semantic Versioning (semver)](https://semver.org/) +- [npm-version](https://docs.npmjs.com/cli/version) +- [Let's stop saying Master/Slave](https://medium.com/@mikebroberts/let-s-stop-saying-master-slave-10f1d1bf34df) + +## Steps for a standard release: + +### via GHA: + +1. An issue titled "Weekly release - DATE" will be created every Tuesday at 15:30 UTC. Go to the [Issues tab](https://github.com/processing/p5.js-web-editor/issues) and click the link in the description to the [Create a release](../.github/workflows/release.yml) GitHub Actions workflow. +2. Run the **Create a release** workflow via "Run workflow". +3. Enter the `version` to release + 1. `version` can be `major`, `minor`, `patch`, etc. (see [npm-version](https://docs.npmjs.com/cli/version) for valid values. +4. Wait for the workflow to run the `verify` job. + 1. This tests the checkout code from `develop`. + 2. If tests fail, the workflow will stop & record its result as a failure. Devs should fix any test failures, then attempt the [Create a release](../.github/workflows/release.yml) workflow again. + 3. If the tests succeed, the workflow will wait on maintainer approval for the `draft-release` job. +5. Go to [Staging](https://stagingeditor.p5js.org) and perform any remaining manual checks. +6. If all looks good, approve the `release` job. + 1. This does the manual steps 5-12 below: + 1. Merges the cut release into `release` + 2. Merges `release` into `develop` + 3. Creates a new draft GitHub release with auto-generated notes & version & tags. +8. [Review the drafted release](https://github.com/processing/p5.js-web-editor/releases) and click **Publish release** when ready. This will then trigger the deployment to [Production](editor.p5js.org). +9. **Manually** verify the release has completed successfully: + 1. `$ kubectl get pods --namespace production` to check the pods are running (this might take a few minutes and you can rerun the command to check again). + 2. Validate that [production](https://stagingeditor.p5js.org/) is working and you are finished! + +### Manually: + 1. `$ git checkout develop` 2. `$ git pull origin develop` 3. `$ git checkout -b release-` @@ -31,8 +57,11 @@ This project's release guide is based on: ## Steps for a Patch Release + Sometimes you might need to push a release for an isolated and small bug fix without what's currently been merged into the `develop` branch. The steps for pushing a Patch Release are similar to a standard Release, except you work with the `release` branch as opposed to `develop`. +This process is not yet automated by the Actions workflow above, so it's still done by hand. + 1. `$ git checkout release` 2. `$ git pull origin release` 3. `$ git checkout -b release-` (increment patch version)