forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add enterprise license for MrRobot@fSociety
- add build system using GHA
- Loading branch information
1 parent
81c8b64
commit 61e0d2f
Showing
5 changed files
with
217 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters