-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (106 loc) · 2.88 KB
/
go.yml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Build and Release
on:
push:
branches: [main]
tags:
- "v*.*.*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Unit Tests
run: go test -v ./... -coverprofile=coverage.out -covermode=atomic
# - name: Generate Coverage HTML
# run: go tool cover -html=coverage.out -o coverage.html
# - name: Code Coverage
# uses: actions/upload-artifact@v4
# with:
# name: coverage
# path: coverage.html
build_cli:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: build
strategy:
matrix:
os:
- 'darwin'
- 'linux'
arch:
- 'amd64'
- 'arm64'
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Build CLI
run: GOOS=${{matrix.os}} GOARCH=${{matrix.arch}} go build -o "./bin/fabled-story-book-${{matrix.os}}-${{matrix.arch}}" ./cmd/cli/main.go
- name: Artifact Upload
uses: actions/upload-artifact@v4
with:
name: fabled-story-book-${{matrix.os}}-${{matrix.arch}}
path: bin/*
build_web:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: acifani/setup-tinygo@v2
with:
tinygo-version: '0.30.0'
- name: Build WASM
run: GOOS=js GOARCH=wasm tinygo build -o ./web/test.wasm -target wasm -no-debug ./cmd/wasm/main.go
- name: Artifact Upload
uses: actions/upload-artifact@v4
with:
name: wasm
path: web/test.wasm
publish_web:
runs-on: ubuntu-latest
needs: build_web
permissions:
contents: read
deployments: write
steps:
- uses: actions/checkout@v4
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: wasm
path: web
- name: Publish Web
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 95ffb963e9a7dc68ae10699ffec445b2
projectName: fabled-story-book
directory: ./web
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
publish_release:
runs-on: ubuntu-latest
needs: [build_cli, publish_web]
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish Release
uses: softprops/action-gh-release@v1
with:
files: |
./dist/*
generate_release_notes: true
name: Fabled Story Book ${{ github.ref_name }}
target_commitish: ${{ github.sha }}