summaryrefslogtreecommitdiffstats
path: root/.github/workflows/release.yml
blob: ec511acbd25ffb2db6e6aba2e884da0a75396c99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Release
'on':
  workflow_run:
    workflows:
      - Tests
    branches:
      - master
    types:
      - completed
jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Check for Go files
        id: check_go
        uses: andstor/file-existence-action@v2
        with:
          files: "**/*.go"

      - name: Fetch all tags
        if: steps.check_go.outputs.files_exists == 'true'
        run: git fetch --force --tags

      - name: Set up Go
        if: steps.check_go.outputs.files_exists == 'true'
        uses: actions/setup-go@v5
        with:
          go-version: 'stable'

      - name: Install GoReleaser
        if: steps.check_go.outputs.files_exists == 'true'
        uses: goreleaser/goreleaser-action@v5
        with:
          install-only: true

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 'lts/*'

      - name: Create Github release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          if [[ "${{ steps.check_go.outputs.files_exists }}" == "true" ]]; then
            npx -p @semantic-release/changelog -p @semantic-release/exec -p @semantic-release/git semantic-release
          else
            npx semantic-release
          fi