-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (139 loc) · 5.15 KB
/
main.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Build and release
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
goarch: [amd64, arm64]
goos: [linux, darwin]
outputs:
bump_tag: ${{ steps.set_output.outputs.bump_tag }}
old_pre_tag: ${{ steps.set_output.outputs.old_pre_tag }}
if: contains(github.event.head_commit.message, 'patch:') || contains(github.event.head_commit.message, 'feat:') || contains(github.event.head_commit.message, 'feat(bump):')
steps:
- uses: actions/checkout@v3
- name: Manage Version
run: |
git fetch --prune --unshallow --tags
CUR_TAG="$(git tag -l | tail -1)"
echo "BUMP_TAG=NULL" >> $GITHUB_ENV
if [[ -z $CUR_TAG ]]; then
echo "CUR_TAG=0.1.0" >> $GITHUB_ENV
echo "OLD_PRE_TAG=NULL" >> $GITHUB_ENV
else
echo "CUR_TAG=$CUR_TAG" >> $GITHUB_ENV
echo "OLD_PRE_TAG=$CUR_TAG" >> $GITHUB_ENV
fi
- name: Increment patch version
id: bump_patch
if: contains(github.event.head_commit.message, 'patch:')
uses: christian-draeger/[email protected]
with:
current-version: ${{ env.CUR_TAG }}
version-fragment: 'bug'
- name: Set env patch
if: contains(github.event.head_commit.message, 'patch:')
run: |
echo "BUMP_TAG=${{ steps.bump_patch.outputs.next-version }}" >> $GITHUB_ENV
echo "PRERELEASE=${{ true }}" >> $GITHUB_ENV
- name: Increment minor version
id: bump_minor
if: contains(github.event.head_commit.message, 'feat:')
uses: christian-draeger/[email protected]
with:
current-version: ${{ env.CUR_TAG }}
version-fragment: 'feature'
- name: Set env minor
if: contains(github.event.head_commit.message, 'feat:')
run: |
echo "BUMP_TAG=${{ steps.bump_minor.outputs.next-version }}" >> $GITHUB_ENV
echo "PRERELEASE=${{ true }}" >> $GITHUB_ENV
- name: Increment major version
id: bump_major
if: contains(github.event.head_commit.message, 'feat(bump):')
uses: christian-draeger/[email protected]
with:
current-version: ${{ env.CUR_TAG }}
version-fragment: 'major'
- name: Set env major
if: contains(github.event.head_commit.message, 'feat(bump):')
run: |
echo "BUMP_TAG=${{ steps.bump_major.outputs.next-version }}" >> $GITHUB_ENV
echo "PRERELEASE=${{ true }}" >> $GITHUB_ENV
- name: Set RELEASE tag
if: contains(github.event.head_commit.message, ':release:')
run: |
echo "PRERELEASE=${{ false }}" >> $GITHUB_ENV
- name: Set up Go
if: env.BUMP_TAG != 'NULL'
uses: actions/setup-go@v3
with:
cache: true
go-version: 1.19
- name: Get dependencies and format
if: env.BUMP_TAG != 'NULL'
run: |
go mod tidy
go fmt ./...
- name: Build and zip binary file
if: env.BUMP_TAG != 'NULL'
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags "-X odoo-one-click/config.VERSION=${{ env.BUMP_TAG }}" -o odoo-one-click .
zip odoo-one-click_${{ matrix.goos }}_${{ matrix.goarch }}.zip odoo-one-click
rm -f odoo-one-click
mkdir -p publish
mv *.zip ./publish/
- name: Set output
id: set_output
if: env.BUMP_TAG != 'NULL'
run: |
echo "bump_tag=${{ env.BUMP_TAG }}" >> $GITHUB_OUTPUT
echo "old_pre_tag=${{ env.OLD_PRE_TAG }}" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@master
if: env.BUMP_TAG != 'NULL'
with:
name: publish-binaries
path: ${{ github.workspace }}/publish
deploy:
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.bump_tag && needs.build.outputs.old_pre_tag
steps:
- name: Delete old prerelease tag with v0.x.x
if: (needs.build.outputs.old_pre_tag == needs.build.outputs.bump_tag) && (needs.build.outputs.bump_tag != 'NULL')
uses: dev-drprasad/[email protected]
with:
delete_release: true
tag_name: ${{ needs.build.outputs.old_pre_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Manage Version
uses: actions/checkout@v3
- name: Restore artifacts
uses: actions/download-artifact@master
if: needs.build.outputs.bump_tag != 'NULL'
with:
name: publish-binaries
path: ${{ github.workspace }}/publish
- name: Get Commits since last Release
id: changelog
uses: simbo/changes-since-last-release-action@v1
with:
line-prefix: "* "
include-hashes: false
- name: Publish GitHub Release
if: needs.build.outputs.bump_tag != 'NULL'
uses: ncipollo/[email protected]
with:
prerelease: env.PRERELEASE
artifacts: "${{ github.workspace }}/publish/*.zip"
tag: "${{ needs.build.outputs.bump_tag }}"
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Changes since ${{ needs.build.outputs.old_pre_tag }}:
${{ steps.changelog.outputs.log }}