Skip to content

progress with update #1284

progress with update

progress with update #1284

Workflow file for this run

name: Build Flarial dll and add to newcdn as a release
on:
push:
branches: [ "*" ]
tags:
- 'beta-*'
- 'release-*'
pull_request:
branches: [ "main", "legacy" ]
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
check-commit:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
type: ${{ steps.check.outputs.type }}
steps:
- name: Check if build is needed
id: check
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
if [[ "${{ github.ref_name }}" == beta-* ]]; then
echo "Build needed for beta tag"
echo "should_build=true" >> "$GITHUB_OUTPUT"
echo "type=2" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.ref_name }}" == release-* ]]; then
echo "Build needed for release tag"
echo "should_build=true" >> "$GITHUB_OUTPUT"
echo "type=1" >> "$GITHUB_OUTPUT"
else
echo "Unknown tag type, skipping build"
echo "should_build=false" >> "$GITHUB_OUTPUT"
fi
elif [[ "${{ github.event.head_commit.message }}" == *"nightly:"* ]] || [[ "${{ github.event.head_commit.message }}" == *"Revert"*"nightly:"* ]]; then
echo "Build needed for nightly"
echo "should_build=true" >> "$GITHUB_OUTPUT"
echo "type=0" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.event.head_commit.message }}" == *"release:"* ]] || [[ "${{ github.event.head_commit.message }}" == *"Revert"*"release:"* ]]; then
echo "Build needed for release"
echo "should_build=true" >> "$GITHUB_OUTPUT"
echo "type=1" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.event.head_commit.message }}" == *"beta:"* ]] || [[ "${{ github.event.head_commit.message }}" == *"Revert"*"beta:"* ]]; then
echo "Build needed for beta"
echo "should_build=true" >> "$GITHUB_OUTPUT"
echo "type=2" >> "$GITHUB_OUTPUT"
else
echo "No build needed, skipping"
echo "should_build=false" >> "$GITHUB_OUTPUT"
fi
windows-build:
runs-on: windows-latest
needs: check-commit
if: needs.check-commit.outputs.should_build == 'true'
outputs:
type: ${{ needs.check-commit.outputs.type }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Up MSVC Environment
uses: ilammy/msvc-dev-cmd@v1
- name: Configure CMake
run: |
#echo 'hi'
cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release
- name: Build DLL
run: |
cmake --build build --target Flarial
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.1
with:
name: Flarial_DLL
path: C:\a\dll\dll\build\Flarial.dll
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.1
with:
name: Flarial_DLL
path: D:\a\dll\dll\build\Flarial.dll
upload-to-cdn:
runs-on: ubuntu-latest
needs: [check-commit, windows-build]
if: needs.check-commit.outputs.should_build == 'true'
steps:
- name: Output commit type
run: echo " ${{env.OUTPUT1}} $OUTPUT1"
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
- name: Checkout newcdn repository
uses: actions/checkout@v4
with:
repository: 'flarialmc/newcdn'
ref: 'main'
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
- name: Download dll
uses: actions/download-artifact@v4.1.9
- name: setup tags
id: tag
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "TAG_NAME=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
elif [[ "${{ env.OUTPUT1 }}" == "0" ]]; then
echo "TAG_NAME=nightly-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
elif [[ "${{ env.OUTPUT1 }}" == "1" ]]; then
echo "TAG_NAME=release-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
elif [[ "${{ env.OUTPUT1 }}" == "2" ]]; then
echo "TAG_NAME=beta-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
fi
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
- name: Nightly Release (CDN)
uses: softprops/action-gh-release@v2
with:
files:
Flarial_DLL/Flarial.dll
tag_name: ${{ env.TAG_NAME}}
body: ${{ github.event.head_commit.message }}
name: "Nightly Release"
repository: flarialmc/newcdn
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
if: ${{ env.OUTPUT1 == 0 }}
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
- name: Nightly Release (Main Repo)
uses: softprops/action-gh-release@v2
with:
files:
Flarial_DLL/Flarial.dll
tag_name: ${{ env.TAG_NAME}}
body: ${{ github.event.head_commit.message }}
name: "Nightly Release"
token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.OUTPUT1 == 0 }}
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
- name: Release (CDN) - File Upload
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@example.com"
cp -f Flarial_DLL/Flarial.dll "./dll/latest.dll"
git add ./dll/latest.dll
git commit -m "Add Release for Release Commit: '${{ github.event.head_commit.message }}'"
git push origin main
echo "uploading as release"
if: ${{ env.OUTPUT1 == 1 }}
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
- name: Release (CDN) - GitHub Release
uses: softprops/action-gh-release@v2
with:
files:
Flarial_DLL/Flarial.dll
tag_name: ${{ env.TAG_NAME}}
body: ${{ github.event.head_commit.message }}
name: "Release"
repository: flarialmc/newcdn
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
if: ${{ env.OUTPUT1 == 1 }}
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
- name: Release (Main Repo)
uses: softprops/action-gh-release@v2
with:
files:
Flarial_DLL/Flarial.dll
tag_name: ${{ env.TAG_NAME}}
body: ${{ github.event.head_commit.message }}
name: "Release"
token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.OUTPUT1 == 1 }}
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
- name: Beta Release (CDN) - File Upload
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@example.com"
cp -f Flarial_DLL/Flarial.dll "./dll/beta.dll"
git add ./dll/beta.dll
git commit -m "Add Beta for Beta Commit: '${{ github.event.head_commit.message }}'"
git push origin main
echo "uploading as beta"
if: ${{ env.OUTPUT1 == 2 }}
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
- name: Beta Release (CDN) - GitHub Release
uses: softprops/action-gh-release@v2
with:
files:
Flarial_DLL/Flarial.dll
tag_name: ${{ env.TAG_NAME}}
body: ${{ github.event.head_commit.message }}
name: "Beta Release"
repository: flarialmc/newcdn
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
if: ${{ env.OUTPUT1 == 2 }}
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
- name: Beta Release (Main Repo)
uses: softprops/action-gh-release@v2
with:
files:
Flarial_DLL/Flarial.dll
tag_name: ${{ env.TAG_NAME}}
body: ${{ github.event.head_commit.message }}
name: "Beta Release"
token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.OUTPUT1 == 2 }}
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}
- name: Cache Github API
run: |
git config user.name "GitHub Actions Bot"
git config user.email "actions@example.com"
curl https://api.github.com/repos/flarialmc/newcdn/tags > cache.txt
git add cache.txt
git commit -m "Add Cache for Tags (API)"
git push origin main
if: ${{ env.OUTPUT1 == 0 }}
env:
OUTPUT1: ${{ needs.windows-build.outputs.type}}
TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }}