-
Notifications
You must be signed in to change notification settings - Fork 13
171 lines (158 loc) · 6.15 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: release
permissions: write-all
jobs:
create_release:
name: create release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: create release
id: create_release
uses: actions/create-release@v1
env:
# for triggering workflow "push-docker-image-release" - https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
GITHUB_TOKEN: ${{ secrets.ANYTYPE_PAT }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: true
build:
name: build release
runs-on: ubuntu-22.04
needs: create_release
strategy:
matrix:
arch:
- amd64
- arm64
os:
- linux
go-version:
- '1.21'
include:
- arch: amd64
rpm_arch: x86_64
- arch: arm64
rpm_arch: aarch64
env:
GOPRIVATE: github.com/anyproto
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '${{ matrix.go-version }}'
check-latest: true
- name: git config
run: git config --global url.https://${{ secrets.ANYTYPE_PAT }}@github.com/.insteadOf https://github.com/
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 6.0
mongodb-replica-set: test-rs
# build {{
- name: deps
run: make deps CGO_ENABLED=0
- name: unit tests
run: make test CGO_ENABLED=0
- name: build
run: make build CGO_ENABLED=0 BUILD_GOARCH=${{ matrix.arch }}
# }}
- name: get release version
id: release-version
run: |
echo "$GITHUB_REF_NAME" | sed 's|^[a-zA-Z]\+|RELEASE_VERSION=|; s|-|_|g' >> $GITHUB_OUTPUT
# create asset {{
- name: create zip archive
if: matrix.os == 'windows'
run: |
zip --junk-paths ${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.zip bin/*
- name: create tar archive
if: matrix.os != 'windows'
run: |
tar \
--create \
--gzip \
--verbose \
--exclude='.gitignore' \
--file=${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.tgz \
--directory=bin/ \
.
- name: create package deb
if: matrix.os == 'linux'
uses: fb929/github-action-fpm@master
with:
fpm_opts:
--name ${{ github.event.repository.name }}
--version ${{ steps.release-version.outputs.RELEASE_VERSION }}
--architecture ${{ matrix.arch }}
--exclude '*/.gitignore'
--exclude '*/.git'
--input-type dir
--output-type deb
fpm_args: ./bin
- name: create package rpm
if: matrix.os == 'linux'
uses: fb929/github-action-fpm@master
with:
fpm_opts:
--name ${{ github.event.repository.name }}
--version ${{ steps.release-version.outputs.RELEASE_VERSION }}
--architecture ${{ matrix.rpm_arch }}
--exclude '*/.gitignore'
--exclude '*/.git'
--input-type dir
--output-type rpm
fpm_args: ./bin
# }}
- name: debug
run: |
ls -al ./
# upload-release-asset {{
- name: upload-release-asset zip
if: matrix.os == 'windows'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.zip
asset_name: ${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.zip
asset_content_type: application/zip
- name: upload-release-asset tgz
if: matrix.os != 'windows'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.tgz
asset_name: ${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}.${{ matrix.os }}-${{ matrix.arch }}.tgz
asset_content_type: application/gzip
- name: upload-release-asset deb
if: matrix.os == 'linux'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}_${{ steps.release-version.outputs.RELEASE_VERSION }}_${{ matrix.arch }}.deb
asset_name: ${{ github.event.repository.name }}_${{ steps.release-version.outputs.RELEASE_VERSION }}_${{ matrix.arch }}.deb
asset_content_type: application/octet-stream
- name: upload-release-asset rpm
if: matrix.os == 'linux'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}-1.${{ matrix.rpm_arch }}.rpm
asset_name: ${{ github.event.repository.name }}-${{ steps.release-version.outputs.RELEASE_VERSION }}-1.${{ matrix.rpm_arch }}.rpm
asset_content_type: application/octet-stream
# }}