DEV Community

Andy Yang
Andy Yang

Posted on

Release 3.2 - Github action

For this release, I choose to work with github action as the external one. The issue I found is https://github.com/infinyon/future-aio/issues/36. The pull request is https://github.com/infinyon/future-aio/pull/44

What is Github action

Github action is a CI/CD tool. We can rent a virtual machine(Linux, Windows,macOS) from GitHub(Azure). For me, it's like a git hook on the cloud. Everytime we change our code (push, PR, tag), we can specify some commands to run, and the results will show on our repo.

Alt Text

How to use it.

All the command for github action is located at .github/workflows/*.yaml. yaml is a superset of JSON. The syntax is like this:

name: node-js-ci

on:
  pull_request:
    branches:
      - master
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ${{matrix.os}}

    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        node-version: [12.x]
Enter fullscreen mode Exit fullscreen mode

We can have different actions for different branches of our repo.

Work with the rust project.

I am new to rust, so first install rust on my MacBook.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Enter fullscreen mode Exit fullscreen mode

After reading the rust document, I know the package tool cargo like npm. For this issue https://github.com/infinyon/future-aio/issues/36, I need to create a release when we have a push with a tag v*. And this is done by the code below.

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: ./changelist.md
          draft: false
          prerelease: false
Enter fullscreen mode Exit fullscreen mode

I also created a ./changelist.md file to track the next release notes. So the release body with replaced by the content of this file.

Alt Text

Top comments (0)