Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automating releases, tags, version, and the generation of the CHANGELOG.md file with github actions #177

Closed
Markkos89 opened this issue Jun 20, 2022 · 1 comment

Comments

@Markkos89
Copy link

Is your feature request related to a problem? Please describe.
No, it's not a problem. Instead is the opposite

Describe the solution you'd like
I build a workflow with github actions to automate the releases with tags and the generation of the CHANGELOG.md file based on the commits format.

I would like to share the basic template of the workflow with you, and if you consider it we can work on it to improve the flow and validations to build the release, etc.

Here is the code:

name: Release new version
on:
  pull_request: 
    branches: [master]
    types: [closed] # merged? here recommend the closed type: https://michaelcurrin.github.io/dev-cheatsheets/cheatsheets/ci-cd/github-actions/triggers.html
    paths-ignore:
      - '*.md'

jobs:
  build:
    name: Publish new release
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [16.x] # Configurable
    # if: github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'staging' # To configure better, for only merged pull requests from staging to main to trigger the steps
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}
          token: ${{ secrets.GITHUB_TOKEN }} # maybe we will need to change it bu as this is a public repo, it may work

      # Generate tag and the version of the current release, without releasing it
      - name: Bump version and push tag
        id: tag_version
        uses: mathieudutour/github-tag-action@v6.0
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          release_branches: master
          pre_release_branches: staging
          append_to_pre_release_tag: 'pre-'

      # Generate the release
      - name: Create a GitHub release
        uses: ncipollo/release-action@v1
        with:
          tag: ${{ steps.tag_version.outputs.new_tag }}
          name: Release ${{ steps.tag_version.outputs.new_tag }}
          body: ${{ steps.tag_version.outputs.changelog }}

      - name: Update Changelog
        uses: stefanzweifel/changelog-updater-action@v1
        with:
          # Pass extracted release date, release notes and version to the Action.
          latest-version: ${{ steps.tag_version.outputs.new_tag }}
          release-notes: ${{ steps.tag_version.outputs.changelog }}
          release-date: ${{ steps.tag_version.outputs.release_date }}
          compare-url-target-revision: ${{ github.event.pull_request.head.ref }}

      - name: Commit updated CHANGELOG
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          skip_fetch: false
          skip_checkout: false
          branch: ${{ github.event.pull_request.base.ref }}
          commit_message: Update CHANGELOG for ${{ steps.tag_version.outputs.new_tag }}
          file_pattern: CHANGELOG.md
          push_options: '--force'
          # I believe we will have to dinamicaly configure this parameters to be able to commit the new changelog.md file
          # commit_user_name: John Doe  # defaults to "github-actions[bot]"
          # commit_user_email: john.doe@mail.com # defaults to "github-actions[bot]@users.noreply.github.com"
          # commit_author: John Doe <john.doe@mail.com> # defaults to author of the commit that triggered the run```

Best regards.
@Can-Sahin
Copy link
Member

Hey cool suggestion but changelog generation is not automated and I gave up this fully automated releases and made it semi-automated. NPM release is anyway manual with 2FA. It causes lot of problems when you wanna eliminate all the manual process. So many cases come up in time. Its like this classic joke eventually; Don't waste time manually doing a task in 6 minutes where you can fail to automate it 6 hours ;)

I would stick with the current version now since I have very limited time. Semi-automated one is working quite nice. Here you can read. Thanks
https://github.com/react-boilerplate/react-boilerplate-cra-template/blob/master/RELEASE_PROCESS.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants