-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (102 loc) · 3.32 KB
/
ci-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
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: "CI/CD for Go"
on: push
jobs:
get-next-version:
runs-on: ubuntu-latest
steps:
- name: "checkout"
uses: actions/checkout@v3
- name: "get branch name"
id: extract_branch_name
shell: bash
run: |
branch_name=$(git rev-parse --abbrev-ref HEAD)
echo "::set-output name=branch::$(echo ${branch_name})"
- name: "setup node"
uses: actions/setup-node@v3
with:
node-version: 19
- name: "init npm"
run: npm init -y
- name: "semantic release - get next version"
id: get-next-version
uses: cycjimmy/semantic-release-action@v3
with:
dry_run: true
#semantic_version: 20.0.2
# you can set branch for semantic-release older than v16.
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'${{ steps.extract_branch_name.outputs.branch }}'
]
env:
#GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "check outputs and env"
run: |
echo "check the result from step `get-next-version`"
pwd
ls -la
set
echo """
new_release_published: ${{ steps.get-next-version.outputs.new_release_published }}
new_release_version: ${{ steps.get-next-version.outputs.new_release_version }}
new_release_major_version: ${{ steps.get-next-version.outputs.new_release_major_version }}
last_release_version: ${{ steps.get-next-version.outputs.last_release_version }}
"""
outputs:
new-release-published: ${{ steps.get-next-version.outputs.new_release_published }}
new-release-version: ${{ steps.get-next-version.outputs.new_release_version }}
build:
runs-on: ubuntu-latest
needs:
- get-next-version
if: needs.get-next-version.outputs.new-release-version != ''
steps:
- uses: actions/checkout@v3
- name: Set up Go environment
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Test
shell: bash
run: |
chmod u+x test.sh
./test.sh
- name: Build
shell: bash
env:
APP_VERSION: ${{ needs.get-next-version.outputs.new-release-version }}
run: |
echo "new release version: ${{ env.APP_VERSION }}"
chmod u+x build.sh
./build.sh ${{ env.APP_VERSION }}
release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: "setup node"
uses: actions/setup-node@v3
with:
node-version: 19
- name: "init npm"
run: npm init -y
- name: "semantic release - create new release"
id: create-new-release
uses: cycjimmy/semantic-release-action@v3
with:
dry_run: false
#semantic_version: 20.0.2
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main'
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}