-
Notifications
You must be signed in to change notification settings - Fork 11
72 lines (64 loc) · 1.76 KB
/
build.yml
File metadata and controls
72 lines (64 loc) · 1.76 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64, arm]
exclude:
- goos: windows
goarch: arm64
- goos: windows
goarch: arm
- goos: darwin
goarch: arm
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22' # Update this to your project's Go version if needed
cache: true
- name: Fetch Dependencies
run: go mod download
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p build
EXT=""
if [ "${{ matrix.goos }}" = "windows" ]; then
EXT=".exe"
fi
go build -ldflags "-s -w -X 'telkomsel-bot/util.version=${{ github.ref_name }}'" -o build/telbot-${{ matrix.goos }}-${{ matrix.goarch }}$EXT .
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: telbot-${{ matrix.goos }}-${{ matrix.goarch }}
path: build/telbot-*
release:
needs: build
runs-on: ubuntu-latest
# Only run this job if a tag was pushed (e.g. v1.0.0)
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/**/*
draft: false
prerelease: false