Skip to content

Commit

Permalink
release ci test
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisCris committed Jan 9, 2025
1 parent 6983751 commit 9ba26f3
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 11 deletions.
83 changes: 77 additions & 6 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
tags:
- "*"
workflow_dispatch:

jobs:
release-build:
Expand All @@ -16,6 +15,9 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -28,32 +30,101 @@ jobs:
with:
node-version: 20

- name: Extract Project Name
shell: bash
id: extract_project_name
run: |
PROJECT_NAME=$(cat pyproject.toml | grep "^name" | awk -F'"' '{print $2}')
if [[ -z "$PROJECT_NAME" ]]; then
echo "Error: Could not extract project name from pyproject.toml"
exit 1
fi
echo "PROJECT_NAME=$PROJECT_NAME" >> $GITHUB_ENV
- name: Set Build Metadata
shell: bash
run: |
CONFIG_FILE="src/palworld_pal_editor/config.py"
VERSION_TAG=$(git describe --tags --abbrev=0)
RELEASE_TYPE="RELEASE"
GIT_HASH=$(git rev-parse --short HEAD)
BUILD_TIME=$(date +%s)
REPO_OWNER="${{ github.repository_owner }}"
REPO_NAME="${{ github.event.repository.name }}"
BRANCH_NAME="${{ github.ref_name }}"
REPO="${REPO_OWNER}/${REPO_NAME}@${BRANCH_NAME}"
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV
echo "GIT_HASH=$GIT_HASH" >> $GITHUB_ENV
if [[ "$RUNNER_OS" == "macOS" ]]; then
sed -i '' "s|^VERSION = .*|VERSION = \"${VERSION_TAG}\"|" $CONFIG_FILE
sed -i '' "s|^RELEASE_TYPE = .*|RELEASE_TYPE = \"${RELEASE_TYPE}\"|" $CONFIG_FILE
sed -i '' "s|^BUILD_TIME = .*|BUILD_TIME = \"${BUILD_TIME}\"|" $CONFIG_FILE
sed -i '' "s|^GIT_HASH = .*|GIT_HASH = \"${GIT_HASH}\"|" $CONFIG_FILE
sed -i '' "s|^REPO = .*|REPO = \"${REPO}\"|" $CONFIG_FILE
else
sed -i "s|^VERSION = .*|VERSION = \"${VERSION_TAG}\"|" $CONFIG_FILE
sed -i "s|^RELEASE_TYPE = .*|RELEASE_TYPE = \"${RELEASE_TYPE}\"|" $CONFIG_FILE
sed -i "s|^BUILD_TIME = .*|BUILD_TIME = \"${BUILD_TIME}\"|" $CONFIG_FILE
sed -i "s|^GIT_HASH = .*|GIT_HASH = \"${GIT_HASH}\"|" $CONFIG_FILE
sed -i "s|^REPO = .*|REPO = \"${REPO}\"|" $CONFIG_FILE
fi
echo "Updated config.py:"
cat $CONFIG_FILE

LAST_TAG=$(git describe --tags --abbrev=0 HEAD^)
COMPARE_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}/compare/${LAST_TAG}...${VERSION_TAG}"
echo "COMPARE_URL=$COMPARE_URL" >> $GITHUB_ENV


- name: Windows Build
if: runner.os == 'Windows'
shell: pwsh
run: |
./build_executable.ps1
$tagName = "${{ github.ref_name }}"
Rename-Item ./dist/palworld-pal-editor.exe "palworld-pal-editor-$tagName-${{ runner.os }}.exe"
- name: Unix-like Build
if: runner.os != 'Windows'
shell: bash
run: |
./build_executable.sh
tagName=${GITHUB_REF#refs/tags/}
mv ./dist/palworld-pal-editor ./dist/palworld-pal-editor-$tagName-${{ runner.os }}
- name: Rename Built File
shell: bash
run: |
FILE_EXT=""
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
FILE_EXT=".exe"
fi
FILE_PATH="./dist/${{ env.PROJECT_NAME }}${FILE_EXT}"
if [[ ! -f "$FILE_PATH" ]]; then
echo "Error: Built file not found: $FILE_PATH"
exit 1
fi
NEW_NAME="Palworld-Pal-Editor_${{ env.VERSION_TAG }}_${{ env.GIT_HASH }}${FILE_EXT}"
mv "$FILE_PATH" "./dist/$NEW_NAME"
echo "Renamed file to: $NEW_NAME"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Palworld_Pal_Editor_${{ runner.os }}_artifact
name: "Palworld-Pal-Editor_${{ runner.os }}_${{ env.VERSION_TAG }}"
path: ./dist/

- name: Create and Upload Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*
body: |
## Changes
View the changes between versions [here](${{ env.COMPARE_URL }}).
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/release-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,49 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Set Build Metadata
shell: bash
run: |
CONFIG_FILE="src/palworld_pal_editor/config.py"
VERSION_TAG=$(git describe --tags --abbrev=0)
if git describe --tags --exact-match > /dev/null 2>&1; then
RELEASE_TYPE="RELEASE"
else
RELEASE_TYPE="NIGHTLY"
fi
GIT_HASH=$(git rev-parse --short HEAD)
BUILD_TIME=$(date +%s)
REPO_OWNER="${{ github.repository_owner }}"
REPO_NAME="${{ github.event.repository.name }}"
BRANCH_NAME="${{ github.ref_name }}"
REPO="${REPO_OWNER}/${REPO_NAME}@${BRANCH_NAME}"
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV
echo "GIT_HASH=$GIT_HASH" >> $GITHUB_ENV
if [[ "$RUNNER_OS" == "macOS" ]]; then
sed -i '' "s|^VERSION = .*|VERSION = \"${VERSION_TAG}\"|" $CONFIG_FILE
sed -i '' "s|^RELEASE_TYPE = .*|RELEASE_TYPE = \"${RELEASE_TYPE}\"|" $CONFIG_FILE
sed -i '' "s|^BUILD_TIME = .*|BUILD_TIME = \"${BUILD_TIME}\"|" $CONFIG_FILE
sed -i '' "s|^GIT_HASH = .*|GIT_HASH = \"${GIT_HASH}\"|" $CONFIG_FILE
sed -i '' "s|^REPO = .*|REPO = \"${REPO}\"|" $CONFIG_FILE
else
sed -i "s|^VERSION = .*|VERSION = \"${VERSION_TAG}\"|" $CONFIG_FILE
sed -i "s|^RELEASE_TYPE = .*|RELEASE_TYPE = \"${RELEASE_TYPE}\"|" $CONFIG_FILE
sed -i "s|^BUILD_TIME = .*|BUILD_TIME = \"${BUILD_TIME}\"|" $CONFIG_FILE
sed -i "s|^GIT_HASH = .*|GIT_HASH = \"${GIT_HASH}\"|" $CONFIG_FILE
sed -i "s|^REPO = .*|REPO = \"${REPO}\"|" $CONFIG_FILE
fi
echo "Updated config.py:"
cat $CONFIG_FILE

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
1 change: 1 addition & 0 deletions frontend/palworld-pal-editor-webui/src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default {
EntryView_BTN_Path_Picker: "Select Path",
EntryView_BTN_Load: "Load Save",
EntryView_Period: ".",
EntryView_Version_Warning: "This version was not built by the official CI/CD pipeline. Please exercise caution and verify the source.",

Editor_Note_Ghost_Pal: "THIS PAL IS LIKELY UNREFERENCED IN GAME",
Editor_Basic_Info: "BASIC INFO",
Expand Down
1 change: 1 addition & 0 deletions frontend/palworld-pal-editor-webui/src/i18n/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default {
EntryView_BTN_Path_Picker: "Sélectionner le chemin",
EntryView_BTN_Load: "Charger la sauvegarde",
EntryView_Period: ".",
EntryView_Version_Warning: "Cette version n'a pas été construite par le pipeline CI/CD officiel. Veuillez faire preuve de prudence et vérifier la source.",

Editor_Note_Ghost_Pal: "CE PAL EST PROBABLEMENT NON RÉFÉRENCÉ DANS LE JEU",
Editor_Basic_Info: "INFOS DE BASE",
Expand Down
1 change: 1 addition & 0 deletions frontend/palworld-pal-editor-webui/src/i18n/ja.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default {
EntryView_BTN_Path_Picker: "パスを選択",
EntryView_BTN_Load: "ロード",
EntryView_Period: "。",
EntryView_Version_Warning: "このバージョンは公式の CI/CD パイプラインでビルドされたものではありません。注意してソースを確認してください。",

Editor_Note_Ghost_Pal: "このパルはゲーム内に存在しない可能性があります",
Editor_Basic_Info: "基本情報",
Expand Down
2 changes: 2 additions & 0 deletions frontend/palworld-pal-editor-webui/src/i18n/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export default {
EntryView_BTN_Path_Picker: "选择路径",
EntryView_BTN_Load: "载入存档",
EntryView_Period: "。",
EntryView_Version_Warning: "此版本不是由官方 CI/CD 管道构建。请谨慎使用并验证来源。",


Editor_Note_Ghost_Pal: "这只帕鲁很可能不存在于游戏中",
Editor_Basic_Info: "基础信息",
Expand Down
6 changes: 6 additions & 0 deletions frontend/palworld-pal-editor-webui/src/stores/paleditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ export const usePalEditorStore = defineStore("paleditor", () => {
// let SELECTED_PAL_EL = null;

// Configs
const VERSION = ref("0.0.0");
const IS_OFFICIAL_BUILD = ref(false);
const I18n = ref(localStorage.getItem("PAL_I18n"));
const PAL_GAME_SAVE_PATH = ref(localStorage.getItem("PAL_GAME_SAVE_PATH"));
const HAS_PASSWORD = ref(false);
Expand Down Expand Up @@ -505,6 +507,8 @@ export const usePalEditorStore = defineStore("paleditor", () => {
PAL_GAME_SAVE_PATH.value = response.data.Path;
}
HAS_PASSWORD.value = response.data.HasPassword;
VERSION.value = response.data.VERSION;
IS_OFFICIAL_BUILD.value = response.data.IsOfficialBuild;
} else if (response.status == 2) {
alert("Unauthorized Access, Please Login. ");
IS_LOCKED.value = true;
Expand Down Expand Up @@ -1395,6 +1399,8 @@ export const usePalEditorStore = defineStore("paleditor", () => {
BASE_PAL_BTN_CLK_FLAG,
PAL_GAME_SAVE_PATH,
PAL_WRITE_BACK_PATH,
VERSION,
IS_OFFICIAL_BUILD,
I18n,
I18nList,
PAL_STATIC_DATA,
Expand Down
34 changes: 32 additions & 2 deletions frontend/palworld-pal-editor-webui/src/views/EntryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const palStore = usePalEditorStore()

<template>
<div id="entryDiv">
<PathPicker/>
<PathPicker />
<div class="left">
<img alt="Vue logo" class="logo" src="@/assets/logo.ico" width="125" height="125" />
<p>{{ palStore.getTranslatedText('EntryView_Greet_1') }}</p>
Expand All @@ -20,7 +20,9 @@ const palStore = usePalEditorStore()
{{ palStore.getTranslatedText('EntryView_Period') }}
</p>
<p>{{ palStore.getTranslatedText('EntryView_Greet_6') }}
<a target="_blank" href="https://github.com/KrisCris/Palworld-Pal-Editor/blob/develop/keep_this_project_alive.md" @click="palStore.SHOW_DONATE_FLAG = true">Donate</a>
<a target="_blank"
href="https://github.com/KrisCris/Palworld-Pal-Editor/blob/develop/keep_this_project_alive.md"
@click="palStore.SHOW_DONATE_FLAG = true">Donate</a>
{{ palStore.getTranslatedText('EntryView_Greet_5') }}
</p>
<p>{{ palStore.getTranslatedText('EntryView_Greet_7') }}
Expand Down Expand Up @@ -52,6 +54,12 @@ const palStore = usePalEditorStore()
{{ palStore.getTranslatedText('EntryView_BTN_Load') }}
</button>
</div>
<div class="version-container">
<p class="version-info">VERSION: {{ palStore.VERSION }}</p>
<p v-if="!palStore.IS_OFFICIAL_BUILD" class="version-warning">
{{ palStore.getTranslatedText("EntryView_Version_Warning") }}
</p>
</div>
</div>
</template>

Expand Down Expand Up @@ -154,4 +162,26 @@ button:disabled {
button:disabled:hover {
background-color: #8a8a8a;
}
/* Style for the version container */
.version-container {
position: fixed;
bottom: 10px;
right: 10px;
text-align: right;
}
/* Style for the version text */
.version-info {
font-size: 0.9rem;
color: #868686;
opacity: 0.7;
}
/* Style for the version warning */
.version-warning {
font-size: 0.8rem;
color: red;
font-weight: bold;
}
</style>
4 changes: 3 additions & 1 deletion src/palworld_pal_editor/api/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from flask import Blueprint, jsonify, request
from flask_jwt_extended import jwt_required

from palworld_pal_editor.config import PROGRAM_PATH, Config
from palworld_pal_editor.config import PROGRAM_PATH, Config, version_info, is_gh_build
from palworld_pal_editor.core import SaveManager
from palworld_pal_editor.utils import LOGGER, DataProvider
from palworld_pal_editor.utils.util import get_path_context, reply
Expand All @@ -22,6 +22,8 @@ def fetch_config():
"I18nList": DataProvider.get_i18n_map(),
"Path": Config.path,
"HasPassword": Config.password != None,
"VERSION": version_info(),
"IsOfficialBuild": is_gh_build(),
},
)

Expand Down
2 changes: 1 addition & 1 deletion src/palworld_pal_editor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def interact_readfunc(self, prompt):
return line

def run(self):
LOGGER.info(f"Palworld Pal Editor v{VERSION}, made by _connlost with ❤.")
LOGGER.info(f"Palworld Pal Editor, made by _connlost with ❤.")
import code
try:
code.interact(banner=InteractThread.banner_message, readfunc=self.interact_readfunc, local=globals())
Expand Down
2 changes: 1 addition & 1 deletion src/palworld_pal_editor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def version_info() -> str:
if RELEASE_TYPE == "RELEASE":
return f"{VERSION}-{RELEASE_TYPE}-{BUILD_TIME}"

def is_gh_build():
def is_gh_build() -> bool:
return version_info() != "development"

class Config:
Expand Down

0 comments on commit 9ba26f3

Please sign in to comment.