From b6989058fc3a7c9692f1e189fee3fbdf28c2e5e7 Mon Sep 17 00:00:00 2001 From: folex <0xdxdy@gmail.com> Date: Tue, 27 Jul 2021 16:41:23 +0300 Subject: [PATCH] Automatically generate changelog (#220) --- .github/workflows/changelog_config.json | 6 +++ .github/workflows/release.yml | 61 +++++++++++-------------- 2 files changed, 32 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/changelog_config.json diff --git a/.github/workflows/changelog_config.json b/.github/workflows/changelog_config.json new file mode 100644 index 00000000..6521ff2e --- /dev/null +++ b/.github/workflows/changelog_config.json @@ -0,0 +1,6 @@ +{ + "template": "## Changes since ${{FROM_TAG}}\n\n${{CHANGELOG}}\n\n${{UNCATEGORIZED}}", + "pr_template": "- #${{NUMBER}} ${{TITLE}}", + "empty_template": "## No changes since ${{FROM_TAG}}", + "sort": "DESC" +} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 82ebdcb5..d4d9714f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,18 +2,10 @@ name: "release" on: push: - # uncomment to release only on tags starting with 'v' - # tags: - # - "v*" branches: - "main" workflow_dispatch: - inputs: - release: - description: "Draft or public release?\nPut 'draft' to make a draft release" - required: false - default: 'public' jobs: release: @@ -33,7 +25,6 @@ jobs: env: BUILD_NUMBER: ${{ github.run_number }} - ### Create release - name: Get project version # In CI sbt appends a new line after its output, so we need `tail -n3 | head -n2` to get last two non-empty lines run: | @@ -68,11 +59,7 @@ jobs: node-version: "14" registry-url: "https://registry.npmjs.org" - - name: Install jq and prepare package - run: | - sudo apt-get update && sudo apt-get --yes --force-yes install jq - PKG_NAME="$(cat package.json | jq -r .name)" - cp ${{ env.JAR }} ./npm/aqua-cli.jar + - run: cp ${{ env.JAR }} ./npm/aqua-cli.jar - run: npm version ${{ env.VERSION }} working-directory: ./npm @@ -82,27 +69,31 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Determine if release should be drafted - run: | - set -x - if [ "${{ github.event.inputs.release }}" = "public" ]; then - echo "DRAFT=false" >> $GITHUB_ENV - else - echo "DRAFT=true" >> $GITHUB_ENV - fi - ### create release - - uses: marvinpinto/action-automatic-releases@latest - # if inputs.release if an empty string, we're running automatically - if: ${{ github.event.inputs.release != '' }} + - name: Push tag ${{ env.BASE_VERSION }} + id: tag_version + uses: mathieudutour/github-tag-action@v5.5 with: - # changelog will be automatically generated from the history - # between tag env.BASE_VERSION (eg 0.1.0 or 0.2.0, etc) - # and the current commit - automatic_release_tag: "${{ env.BASE_VERSION }}" - title: "Aqua Compiler ${{ env.VERSION }}" - files: | - ${{ env.JAR }} - draft: ${{ env.DRAFT }} + custom_tag: ${{ env.BASE_VERSION }} + tag_prefix: "" + github_token: ${{ secrets.PERSONAL_TOKEN }} + + - name: Build Changelog + id: github_release + uses: mikepenz/release-changelog-builder-action@v1 + with: + configuration: ".github/workflows/changelog_config.json" + toTag: ${{ steps.tag_version.outputs.new_tag }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Release + uses: softprops/action-gh-release@v1 + with: + name: Aqua Compiler ${{ env.VERSION }} + tag_name: ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.github_release.outputs.changelog }} + draft: false prerelease: false - repo_token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}