forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (149 loc) · 5.66 KB
/
server-ci-enterprise.yaml
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
name: Server CI Enterprise
on:
workflow_dispatch:
push:
branches:
- release-*
tags:
- v*
concurrency:
group: mattermost-enterprise-linux-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build-server:
runs-on: ubuntu-latest
defaults:
run:
working-directory: server
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: webapp/package-lock.json
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: server/.go-version
cache-dependency-path: |
server/go.mod
server/public/go.sum
- name: Configure Enterprise edition
run: |
mkdir -p ../enterprise-dir/imports ../enterprise-dir/cloud/config
cp enterprise/placeholder.go ../enterprise-dir/imports/imports.go
cp enterprise/LICENSE ../enterprise-dir/ENTERPRISE-EDITION-LICENSE.txt
touch ../enterprise-dir/cloud/config/cloud_defaults.json
- name: Build
env:
BUILD_NUMBER: ${{ github.ref_name }}-${{ github.run_number }}
BUILD_ENTERPRISE_DIR: ../enterprise-dir
run: |
make config-reset
make build-cmd
make package
- name: Persist dist artifacts
uses: actions/upload-artifact@v4
with:
name: server-dist-artifact
path: server/dist/
retention-days: 14
- name: Create GitHub Release
uses: actions/github-script@v7
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
env:
TAG_NAME: ${{ github.ref_name }}
RELEASE_NAME: ${{ github.ref_name }}
BODY: "Full Changelog: https://github.com/${{ github.repository }}/commits/${{ github.ref_name }}"
ASSETS: >-
server/dist/mattermost-enterprise-linux-amd64.tar.gz,
server/dist/mattermost-enterprise-linux-arm64.tar.gz,
server/dist/mattermost-enterprise-osx-amd64.tar.gz,
server/dist/mattermost-enterprise-osx-arm64.tar.gz,
server/dist/mattermost-enterprise-windows-amd64.zip
with:
script: |
const fs = require('fs');
const path = require('path');
const { TAG_NAME, RELEASE_NAME, BODY, ASSETS } = process.env;
const assets = ASSETS.split(',');
let uploadUrl = '';
try {
const response = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: TAG_NAME,
name: RELEASE_NAME,
body: BODY,
draft: false,
prerelease: false,
});
console.log(`Release created: ${response.data.html_url}`);
uploadUrl = response.data.upload_url;
} catch (error) {
if (error.response && error.response.status === 422) {
core.warning(`Release already exists for tag ${TAG_NAME}. Skipping release creation and asset uploads.`);
return;
} else {
core.setFailed(`Error creating release: ${error.message}`);
return;
}
}
if (uploadUrl) {
for (const asset of assets) {
const assetPath = path.join(process.env.GITHUB_WORKSPACE, asset.trim());
const contentType = asset.endsWith('.zip') ? 'application/zip' : 'application/gzip';
const filename = path.basename(assetPath);
console.log(`Uploading asset: ${filename}`);
try {
const uploadResponse = await github.rest.repos.uploadReleaseAsset({
url: uploadUrl,
headers: {
'content-type': contentType,
'content-length': fs.statSync(assetPath).size
},
name: filename,
data: fs.readFileSync(assetPath),
});
console.log(`Asset uploaded: ${uploadResponse.data.browser_download_url}`);
} catch (uploadError) {
core.error(`Error uploading asset: ${filename}, ${uploadError.message}`);
}
}
}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker image
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/tuxity/mattermost-enterprise-edition
flavor: |
latest=false
tags: |
type=semver,pattern={{version}},value=${{ github.ref_name }}
type=raw,value=latest,enable=${{ !startsWith(github.ref, 'refs/tags/v') }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: server/build
build-contexts:
dist=server/dist
build-args:
MM_PACKAGE=file:///tmp/mattermost-enterprise-linux-amd64.tar.gz
platforms: linux/amd64
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max