-
Notifications
You must be signed in to change notification settings - Fork 2
92 lines (78 loc) · 2.42 KB
/
release.yaml
File metadata and controls
92 lines (78 loc) · 2.42 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Release
on:
release:
types: [published]
jobs:
init:
name: 🚩 Initialize
runs-on: ubuntu-latest
steps:
- name: Cancel previous workflow
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ secrets.PAT }}
build:
name: ✏️ Generate
runs-on: ubuntu-20.04
needs: init
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
- name: Get version
run: echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Cleanup
run: rm -rf api docs test *.go go.* .gitignore
- name: OpenAPI Generator
uses: hatamiarash7/openapi-generator@main
with:
generator: go
generator-tag: v6.6.0
config-file: .github/generator/config.yml
openapi-url: https://www.arvancloud.ir/api-docs/cdn-4.0.yml
command-args: "--http-user-agent r1c-cdn-sdk"
output-dir: "/github/workspace"
template-dir: .github/generator/template/
- name: Update output
run: bash .github/generator/tune.sh
- name: Get version
id: version
uses: jbutcher5/read-yaml@main
with:
file: "./api/openapi.yaml"
key-path: '["info", "version"]'
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: "1.18"
- name: Build
env:
GOOS: linux
GOARCH: amd64
CGO_ENABLED: 0
LDFLAGS: -s -w
run: go build -trimpath -ldflags "$LDFLAGS" -o "./cdn" .
- name: Test
run: |
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
go test -v -race ./... -json > TestResults.json
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: Test-results
path: TestResults.json
- name: Cleanup
run: rm -rf cdn TestResults.json
- name: Commit & Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: "SDK ${{ env.APP_VERSION }} - API v${{ steps.version.outputs.data }}"
commit_user_name: "ArvanCloud"
commit_user_email: "cdn.sre@arvancloud.ir"
commit_author: Arash <arash.r1c@gmail.com>