sue445/zatsu_monitor

View on GitHub
.github/workflows/release.yml

Summary

Maintainability
Test Coverage
name: Release
on:
  push:
    branches:
      - "!**/*"
    tags:
      - "v*"

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: Check out code into the Go module directory
        uses: actions/checkout@v4

      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version-file: "go.mod"
        id: go

      - name: make package and release
        run: |
          set -xe
          export GOPATH=`go env GOPATH`
          export PUSH_EVENT_REF=$(jq --raw-output .ref "$GITHUB_EVENT_PATH")

          if [ "$(echo $PUSH_EVENT_REF | grep refs/tags/ | wc -l)" = "0" ]; then
            echo "ref is not a tag: ${PUSH_EVENT_REF}"
            exit 1
          fi

          export TAGNAME=$(echo $PUSH_EVENT_REF | sed -e 's!refs/tags/!!g')

          make clean package
          go install github.com/tcnksm/ghr@latest
          $GOPATH/bin/ghr -n ${TAGNAME} -b "Release ${TAGNAME}" ${TAGNAME} dist/
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Slack Notification
        uses: homoluctus/slatify@master
        if: always()
        with:
          job_name: '*release*'
          type: ${{ job.status }}
          icon_emoji: ":octocat:"
          url: ${{ secrets.SLACK_WEBHOOK }}
          token: ${{ secrets.GITHUB_TOKEN }}