From c757859d3601a6bd9b2d08062c0a10436ec61072 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 12 Mar 2024 17:46:08 +0100 Subject: [PATCH] DX: import deployment workflows (#6) * DX: add release drafter * DX: add PR linting * DX: add CD workflow for pushing to version branches --- .github/release-drafter.yml | 37 +++++++++++++++++++++++++++ .github/workflows/cd.yml | 33 ++++++++++++++++++++++++ .github/workflows/pr-linting.yml | 33 ++++++++++++++++++++++++ .github/workflows/release-drafter.yml | 16 ++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/pr-linting.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..394a977 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,37 @@ +name-template: update-pip-constraints $NEXT_PATCH_VERSION +tag-template: $NEXT_PATCH_VERSION + +references: + - main + - epic/* + +categories: + - title: ✨ New features + label: ✨ Feature + - title: ⚠️ Enhancements and optimizations + label: ⚙️ Enhancement + - title: ⚠️ API changes + label: ⚠️ Interface + - title: ⚠️ Changes that may affect behavior + label: ❗ Behavior + - title: 🐛 Bug fixes + label: 🐛 Bug + - title: 📝 Documentation + label: 📝 Docs + - title: 🔨 Maintenance + label: 🔨 Maintenance + - title: 🖱️ Developer Experience + label: 🖱️ DX + +change-template: "- $TITLE (#$NUMBER)" + +replacers: + - search: /([A-Z]+!?:\s*)(.*)/g + replace: $2 + +sort-direction: ascending + +template: | + $CHANGES + + _The full changelog as commits can be found [here](https://github.com/ComPWA/update-pip-constraints/compare/$PREVIOUS_TAG...$NEXT_PATCH_VERSION)._ diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..62e54df --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,33 @@ +name: CD + +on: + release: + types: + - prereleased + - released + +jobs: + milestone: + if: startsWith(github.ref, 'refs/tags') + uses: ComPWA/actions/.github/workflows/close-milestone.yml@v1 + push-to-version-branches: + name: Push to version branches + if: startsWith(github.ref, 'refs/tags') && !github.event.release.prerelease + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Configure Git credentials + run: | + git config --global user.name "GitHub Action" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + - name: Push to matching minor version branch + env: + TAG: ${{ github.ref_name }} + run: | + re='^(v?)([0-9]+)\.([0-9]+)\.[0-9]+' + if [[ $TAG =~ $re ]]; then + MAJOR_VERSION="${BASH_REMATCH[2]}" + MINOR_VERSION="${BASH_REMATCH[2]}.${BASH_REMATCH[3]}" + git push origin HEAD:refs/heads/v$MAJOR_VERSION --force + git push origin HEAD:refs/heads/v$MINOR_VERSION --force + fi diff --git a/.github/workflows/pr-linting.yml b/.github/workflows/pr-linting.yml new file mode 100644 index 0000000..b001488 --- /dev/null +++ b/.github/workflows/pr-linting.yml @@ -0,0 +1,33 @@ +name: PR linting +on: + pull_request: + types: + - edited + - labeled + - opened + - reopened + - synchronize + - unlabeled + +jobs: + check-labels: + name: Check labels + runs-on: ubuntu-22.04 + steps: + - uses: docker://agilepathway/pull-request-label-checker:latest + with: + any_of: >- + 🐛 Bug,✨ Feature,⚙️ Enhancement,⚠️ Interface,❗ Behavior,📝 Docs,🔨 Maintenance,🖱️ DX + none_of: Epic,💫 Good first issue + repo_token: ${{ secrets.GITHUB_TOKEN }} + + check-title: + name: Check title + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - run: npm install @compwa/commitlint-config + - name: Create commitlint config + run: | + echo "module.exports = {extends: ['@compwa/commitlint-config']}" > commitlint.config.js + - uses: JulienKode/pull-request-name-linter-action@v0.5.0 diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..5234093 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,16 @@ +name: Release Drafter + +on: + push: + branches: + - main + - epic/* + workflow_dispatch: + +jobs: + update_release_draft: + runs-on: ubuntu-22.04 + steps: + - uses: release-drafter/release-drafter@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}