From 46c77a6e8df95477b8a7dfa3ad126a8e52a78541 Mon Sep 17 00:00:00 2001 From: Andreas Hammerbeck Date: Thu, 23 May 2024 12:30:37 +0200 Subject: [PATCH] Automate release notes (#442) * Automate release note generation * Automate github release when deploying to production * update readme --------- Co-authored-by: Hammerbeck --- .../actions/get-current-version/action.yml | 5 +-- .github/actions/release-to-git/action.yml | 37 +++++++++++++++++++ .github/release.yml | 24 ++++++++++++ .github/workflows/ci-cd.yaml | 18 +++++++++ README-infrastructure.md | 5 ++- 5 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 .github/actions/release-to-git/action.yml create mode 100644 .github/release.yml diff --git a/.github/actions/get-current-version/action.yml b/.github/actions/get-current-version/action.yml index 2b43b5ac..191d4452 100644 --- a/.github/actions/get-current-version/action.yml +++ b/.github/actions/get-current-version/action.yml @@ -5,7 +5,7 @@ description: "Get the current version from a file and the git short sha" outputs: version: description: "Version" - value: ${{ steps.get-current-version.outputs.version }} + value: ${{ steps.set-current-version.outputs.version }} gitShortSha: description: "Git short sha" value: ${{ steps.set-git-short-sha.outputs.gitShortSha }} @@ -28,9 +28,8 @@ runs: id: set-git-short-sha shell: bash run: echo "gitShortSha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - + - name: Set image tag id: set-image-tag shell: bash run: echo "imageTag=$(cat version.txt)-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - diff --git a/.github/actions/release-to-git/action.yml b/.github/actions/release-to-git/action.yml new file mode 100644 index 00000000..5dbefc56 --- /dev/null +++ b/.github/actions/release-to-git/action.yml @@ -0,0 +1,37 @@ +name: Create release in github + +description: Create a release to git if the version has been bumped in the version.txt file + +inputs: + GITHUB_TOKEN: + description: "GitHub token" + required: true + default: ${{ github.token }} + +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + + - name: Get version + id: get-version + uses: ./.github/actions/get-current-version + + - name: fetch tags + shell: bash + run: git fetch --tags + + - name: set latest tag + shell: bash + id: set-latest-tag + run: | + echo "latestTag=$(git tag | sort --version-sort | tail -n1)" >> $GITHUB_OUTPUT + + - name: Create release + shell: bash + if: ${{ !(steps.set-latest-tag.outputs.latestTag == steps.get-version.outputs.version) }} + env: + GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} + TAG: ${{ steps.get-version.outputs.version }} + run: | + gh release create "$TAG" --title="v${{steps.get-version.outputs.version}}" --generate-notes --target feat/automatic-release-notes diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000..b7e47d22 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,24 @@ +changelog: + exclude: + labels: + - ignore-for-release + categories: + - title: Breaking Changes 🛠 + labels: + - kind/breaking-change + - title: New Features 🎉 + labels: + - kind/feature + - title: Bugfixes 🐛 + labels: + - kind/bug + - title: Other Changes + labels: + - kind/other + - kind/user-story + - title: Dependency Upgrades 📦 + labels: + - kind/dependencies + - title: Uncategorized changes + labels: + - "*" diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 3f16efc5..edb14e0d 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -108,3 +108,21 @@ jobs: hasAzureChanges: ${{ needs.check-for-changes.outputs.hasAzureChanges }} hasBackendChanges: ${{ needs.check-for-changes.outputs.hasBackendChanges }} hasMigrationChanges: ${{ needs.check-for-changes.outputs.hasMigrationChanges }} + + release-to-git: + name: release to git + runs-on: ubuntu-latest + needs: [check-for-changes, deploy-production] + if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' && !failure() && !cancelled()}} + permissions: + id-token: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: release + if: (!failure() && !cancelled()) + uses: ./.github/actions/release-to-git + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/README-infrastructure.md b/README-infrastructure.md index f1aaf00b..d295ce98 100644 --- a/README-infrastructure.md +++ b/README-infrastructure.md @@ -101,4 +101,7 @@ https://pedia.altinn.cloud/altinn-3/ops/release-and-deploy/api-management/ ## After deployment of infrastructure -It's important to check that Microsoft Defender is enabled for all blob storages in the environment. \ No newline at end of file +It's important to check that Microsoft Defender is enabled for all blob storages in the environment. + +## Create release notes +If the version in version.txt is bumped, a new release in github will automaticly be created the next time the production environment is deployed. \ No newline at end of file