-
Notifications
You must be signed in to change notification settings - Fork 32
138 lines (131 loc) · 6.41 KB
/
release.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: 🚀 Release
on:
release: {types: [published]}
workflow_dispatch: {}
jobs:
build-web:
name: Build the frontend
runs-on: ubuntu-latest
env: {FORCE_COLOR: 'true', NPM_PREFIX: './web'}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: {node-version-file: ./web/package.json, cache: 'npm', cache-dependency-path: ./web/package-lock.json}
- run: npm --prefix "$NPM_PREFIX" install -dd --no-audit
- run: npm --prefix "$NPM_PREFIX" run generate
- run: npm --prefix "$NPM_PREFIX" run build
- uses: actions/upload-artifact@v4
with: {name: web-dist, path: ./web/dist/, if-no-files-found: error, retention-days: 1}
build-app:
name: Build the app
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64]
needs: [build-web]
steps:
- uses: actions/checkout@v4
- {uses: gacts/github-slug@v1, id: slug}
- id: values
run: |
echo "bin-name=webhook-tester-${{ matrix.os }}-${{ matrix.arch }}`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`" >> $GITHUB_OUTPUT
- {uses: actions/setup-go@v5, with: {go-version-file: go.mod}}
- run: go install "github.com/oapi-codegen/oapi-codegen/v2/cmd/[email protected]"
- run: go generate -skip readme ./...
- {uses: actions/download-artifact@v4, with: {name: web-dist, path: ./web/dist}} # put the built frontend
- env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 0
LDFLAGS: -s -w -X gh.tarampamp.am/webhook-tester/v2/internal/version.version=${{ steps.slug.outputs.version-semantic }}
run: go build -trimpath -ldflags "$LDFLAGS" -o "./${{ steps.values.outputs.bin-name }}" ./cmd/webhook-tester/
- uses: actions/upload-artifact@v4
with:
name: webhook-tester-${{ matrix.os }}-${{ matrix.arch }}
path: ./${{ steps.values.outputs.bin-name }}
if-no-files-found: error
retention-days: 1
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./${{ steps.values.outputs.bin-name }}
asset_name: ${{ steps.values.outputs.bin-name }}
tag: ${{ github.ref }}
build-deb-package:
name: Build the Debian package
runs-on: ubuntu-latest
strategy: {matrix: {arch: [amd64, arm64]}}
needs: [build-app]
steps:
- {uses: gacts/github-slug@v1, id: slug}
- {uses: actions/download-artifact@v4, with: {name: "webhook-tester-linux-${{ matrix.arch }}"}}
- id: values
run: |
majorMinorPatch="${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}.${{ steps.slug.outputs.version-patch }}"
echo "version=${majorMinorPatch}" >> $GITHUB_OUTPUT
echo "pkg-name=webhook-tester_${majorMinorPatch}-1_${{ matrix.arch }}" >> $GITHUB_OUTPUT
- run: |
mkdir -p ./${{ steps.values.outputs.pkg-name }}/usr/local/bin ./${{ steps.values.outputs.pkg-name }}/DEBIAN
mv ./webhook-tester-linux-${{ matrix.arch }} ./${{ steps.values.outputs.pkg-name }}/usr/local/bin/webhook-tester
echo -e "Package: webhook-tester\nVersion: ${{ steps.values.outputs.version }}" > ./${{ steps.values.outputs.pkg-name }}/DEBIAN/control
echo -e "Architecture: ${{ matrix.arch }}\nMaintainer: ${{ github.actor }}" >> ./${{ steps.values.outputs.pkg-name }}/DEBIAN/control
echo -e "Description: Powerful tool for testing WebHooks and more" >> ./${{ steps.values.outputs.pkg-name }}/DEBIAN/control
dpkg-deb --build --root-owner-group ${{ steps.values.outputs.pkg-name }}
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./${{ steps.values.outputs.pkg-name }}.deb
asset_name: webhook-tester-linux-${{ matrix.arch }}.deb
tag: ${{ github.ref }}
build-docker-image:
name: Build the docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
- {uses: gacts/github-slug@v1, id: slug}
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
build-args: "APP_VERSION=${{ steps.slug.outputs.version-semantic }}"
tags: |
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:latest
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version }}
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}
ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version-major }}
docker.io/tarampampam/webhook-tester:latest
docker.io/tarampampam/webhook-tester:${{ steps.slug.outputs.version }}
docker.io/tarampampam/webhook-tester:${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}
docker.io/tarampampam/webhook-tester:${{ steps.slug.outputs.version-major }}
deploy-on-render:
name: Deploy on Render
runs-on: ubuntu-latest
concurrency: {group: render}
environment: {name: render}
needs: [build-docker-image]
steps:
- {uses: gacts/github-slug@v1, id: slug}
# https://render.com/docs/deploy-an-image#deploy-via-webhook
- run: curl -SsL "https://api.render.com/deploy/${SRV}?key=${KEY}&imgURL=${IMG}:${TAG}"
env:
SRV: ${{ secrets.RENDER_COM_SERVICE_ID }}
KEY: ${{ secrets.RENDER_COM_DEPLOY_KEY }}
IMG: docker.io/tarampampam/webhook-tester
TAG: ${{ steps.slug.outputs.version }} # the same as in the "build-docker-image" job