DEV Community

loading...

Release 0.42 - Three ideas about automating release.

yzwdroid profile image Andy Yang ・2 min read

The current release process

The telescope project https://github.com/Seneca-CDOT/telescope.git use release-it https://www.npmjs.com/package/release-it as the release tool. To automate the release process, I have three ideas.

Idea one: release-it

The release-it tool have a ci mode release-it --ci, it will automate the process without any prompt. We can also continue our release process like before, just moving to the cloud.

But I have two problems:

  • Problem one: read the GITHUB-TOKEN.

I have tried

- name: export env
        run: export GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" 
Enter fullscreen mode Exit fullscreen mode

and

- name: Create Release
  run: npm run release
  env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}" 
Enter fullscreen mode Exit fullscreen mode

none of them work.

  • Problem two: triger the release

We triger the release when push to github with the tag v*, but release-it also add a new tag when create the new release.

Idea two:

We maintain a file CHANGLOG.md.

on:
  push:
    tags:
      - 'v*'

name: Create Release

jobs:
  build:
    name: Create Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          body_path: ./CHANGELOG.md
          draft: false
          prerelease: false
Enter fullscreen mode Exit fullscreen mode

Idea Three: Release Drafter

We can draft a release as we commiting to the repo.
https://github.com/marketplace/actions/release-drafter

name: Release Drafter

on:
  push:
    # branches to consider in the event; optional, defaults to all
    branches:
      - $default-branch

jobs:
  update_release_draft:
    runs-on: ubuntu-latest
    steps:
      # Drafts your next Release notes as Pull Requests are merged into "master"
      - uses: release-drafter/release-drafter@v5
        with:
          # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
          # config-name: my-config.yml
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide