Skip to content

Depot++

Depot++ #192

###
### Copyright (c) 2024 Carbon Community
### All rights reserved
###
name: Production Build
concurrency: build-1-production
on:
push:
branches:
- production
workflow_dispatch:
jobs:
bootstrap:
name: 🥾 Bootstrap
runs-on: ubuntu-latest
outputs:
date: ${{ steps.step1.outputs.date }}
clock: ${{ steps.step1.outputs.clock }}
tag: ${{ steps.step1.outputs.tag }}
ref: ${{ steps.step1.outputs.ref }}
wipe: ${{ steps.step1.outputs.wipe }}
version: ${{ steps.step1.outputs.version }}
steps:
#- name: Log environment
# uses: crazy-max/ghaction-dump-context@v1
- name: 🔗 Checkout source code from github
uses: actions/checkout@v3
with:
ref: production
- name: 📅 Prepare the environment
id: step1
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "clock=$(date +'%H:%M:%S')" >> $GITHUB_OUTPUT
echo "tag=$(date +'%Yd%j')" >> $GITHUB_OUTPUT
echo "ref=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "wipe=$( [ $(date +%u) -eq 4 ] && [ $(date +%d) -le 7 ] && echo true || echo false )" >> $GITHUB_OUTPUT
echo "version=2.0.$(curl -s -L 'https://carbonmod.gg/version?id=production&token=${{secrets.VERSIONS_TOKEN}}')" >> $GITHUB_OUTPUT
# BUILD LINUX ----------------------------------------------------------------
build-linux:
name: 🐧 Linux
needs: bootstrap
runs-on: ubuntu-20.04
continue-on-error: false
outputs:
wipe: ${{ needs.bootstrap.outputs.wipe }}
artifact: build-production-${{ needs.bootstrap.outputs.ref }}-linux
build_info: Built at ${{ needs.bootstrap.outputs.date }} ${{ needs.bootstrap.outputs.clock }} based on commit ${{ needs.bootstrap.outputs.ref }}.
steps:
- name: 🔗 Checkout source code from github
uses: actions/checkout@v3
with:
ref: production
token: ${{ secrets.PAT_ALL_REPO }}
submodules: recursive
- name: 🛤️ Setup the dotnet build environment
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.0.x
- uses: dtolnay/rust-toolchain@stable
- uses: ClementTsang/cargo-action@v0.0.3
with:
command: build
args: -r --target x86_64-unknown-linux-gnu
directory: Carbon.Core/Carbon.Native
- name: 🔨 Setup the Carbon build environment
shell: bash
run: |
${GITHUB_WORKSPACE}/Tools/Build/linux/bootstrap.sh
- name: 🐧 Built Carbon on Linux
shell: bash
run: |
export VERSION=${{ needs.bootstrap.outputs.version }}
${GITHUB_WORKSPACE}/Tools/Build/linux/build.sh ReleaseUnix "PROD" "production_build"
${GITHUB_WORKSPACE}/Tools/Build/linux/build.sh MinimalUnix "PROD" "production_build"
- name: ⬆️ Upload the artifacts
uses: actions/upload-artifact@v3
with:
name: build-production-linux
path: |
Release/Carbon.Linux.Release.tar.gz
Release/Carbon.Linux.Release.info
Release/Carbon.Linux.Minimal.tar.gz
Release/Carbon.Linux.Minimal.info
# BUILD WINDOWS --------------------------------------------------------------
build-windows:
name: 💻 Windows
needs: bootstrap
runs-on: windows-latest
continue-on-error: false
steps:
- name: 🔗 Checkout source code from github
uses: actions/checkout@v3
with:
ref: production
token: ${{ secrets.PAT_ALL_REPO }}
submodules: recursive
- name: 🛤️ Setup the dotnet build environment
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.0.x
- uses: dtolnay/rust-toolchain@stable
- uses: ClementTsang/cargo-action@v0.0.3
with:
command: build
args: -r --target x86_64-pc-windows-msvc
directory: Carbon.Core/Carbon.Native
- name: 🔨 Setup the Carbon build environment
shell: cmd
run: |
%GITHUB_WORKSPACE%\Tools\Build\win\bootstrap.bat
- name: 🔨 Built Carbon on Windows
shell: cmd
run: |
set VERSION=${{ needs.bootstrap.outputs.version }}
call %GITHUB_WORKSPACE%\Tools\Build\win\build.bat Release PROD production_build
call %GITHUB_WORKSPACE%\Tools\Build\win\build.bat Minimal PROD production_build
- name: ⬆️ Upload the artifacts
uses: actions/upload-artifact@v3
with:
name: build-production-windows
path: |
Release/Carbon.Windows.Release.zip
Release/Carbon.Windows.Release.info
Release/Carbon.Windows.Minimal.zip
Release/Carbon.Windows.Minimal.info
- name: 🔨 Upload NuGet package
shell: cmd
run: |
%GITHUB_WORKSPACE%\Tools\Build\win\publish_nuget.bat ${{ secrets.NUGET_API }} ${{ needs.bootstrap.outputs.version }}
# RELEASE --------------------------------------------------------------------
release-on-schedule:
name: 💾 Production Release
needs: [ "bootstrap", "build-linux", "build-windows" ]
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (github.event_name == 'schedule' && needs.build-linux.outputs.wipe == 'true') }}
steps:
- name: 🗑️ Delete existing release tag
uses: dev-drprasad/delete-tag-and-release@92d94d77429cb0436597047a92369526a5824f50
with:
delete_release: true
tag_name: production_build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 💤 Sleep for 5 seconds
run: sleep 5s
shell: bash
- name: ⬇️ Download artifacts
uses: actions/download-artifact@v3
with:
path: Release/
- name: Display structure of downloaded files
run: ls -R
working-directory: Release
- name: 🏷️ Update release tag
uses: softprops/action-gh-release@d4e8205d7e959a9107da6396278b2f1f07af0f9b
with:
draft: false
prerelease: false
tag_name: production_build
name: 'Production Build — v${{ needs.bootstrap.outputs.version }}'
body: |
This is a release build of Carbon based on the `production` branch.
This build is targeted at the general public.
### How to install
1. Download the `Carbon.[Windows|Linux].Release` archive from the attachments below.
2. Unzip the archive to the root of your Rust Dedicated Server.
3. Restart the server and enjoy.
${{ needs.build-linux.outputs.build_info }}
files: |
Release/build-production-linux/Carbon.Linux.Release.info
Release/build-production-linux/Carbon.Linux.Release.tar.gz
Release/build-production-windows/Carbon.Windows.Release.info
Release/build-production-windows/Carbon.Windows.Release.zip
Release/build-production-linux/Carbon.Linux.Minimal.info
Release/build-production-linux/Carbon.Linux.Minimal.tar.gz
Release/build-production-windows/Carbon.Windows.Minimal.info
Release/build-production-windows/Carbon.Windows.Minimal.zip