-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Skip CI] feat: Merge 'release' to 'master'
Signed-off-by: JyCyunMe <[email protected]>
- Loading branch information
Showing
56 changed files
with
2,612 additions
and
1,050 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,41 @@ | ||
# 获取Git信息 | ||
|
||
$GIT_BRANCH = $env:GITHUB_REF -replace "refs/heads/", "" | ||
$VERSION_REGEXP = "^v?\d+\.\d+\.\d+(\.\d+)?(-pre)?$" | ||
$VERSION_RELEASE_REGEXP = "^v?\d+\.\d+\.\d+(\.\d+)?$" | ||
$VERSION_PRE_REGEXP = "^v?\d+\.\d+\.\d+(\.\d+)?-pre$" | ||
echo "VERSION_REGEXP=$VERSION_REGEXP" >> $env:GITHUB_ENV | ||
echo "VERSION_RELEASE_REGEXP=$VERSION_RELEASE_REGEXP" >> $env:GITHUB_ENV | ||
echo "VERSION_PRE_REGEXP=$VERSION_PRE_REGEXP" >> $env:GITHUB_ENV | ||
$GIT_BRANCH = $env:GITHUB_REF -replace "refs/heads/", "" | ||
echo "GIT_BRANCH=$GIT_BRANCH" >> $env:GITHUB_ENV | ||
echo "Current Branch: $GIT_BRANCH" | ||
|
||
$SHORT_SHA = ${env:GITHUB_SHA}.Substring(0, 7) | ||
echo "SHORT_SHA=$SHORT_SHA" >> $env:GITHUB_ENV | ||
echo "Current commit hash id: ${env:GITHUB_SHA} ($SHORT_SHA)" | ||
|
||
$GIT_TAG_RELEASE_VERSION = git tag -l | where { $_ -match $VERSION_RELEASE_REGEXP } | sort -Descending -Top 1 | ||
$preTagList = $( git tag -l | where { $_ -match $VERSION_PRE_REGEXP } ) | ||
for($i = 0; $i -lt $preTagList.Length; $i++) { | ||
$preTagList[$i] = $preTagList[$i].Replace("-pre", "").Replace("v", "") | ||
} | ||
$GIT_TAG_PRE_VERSION = $preTagList | sort -Property { [version]$_ } -Descending -Top 1 | ||
|
||
$GIT_TAG_PRE_LATEST = "v${GIT_TAG_PRE_VERSION}-pre" | ||
$GIT_TAG_RELEASE_LATEST = $GIT_TAG_RELEASE_VERSION | ||
$GIT_TAG_RELEASE_VERSION = $GIT_TAG_RELEASE_VERSION.Replace("v", "") | ||
if ($GIT_TAG_PRE_VERSION -eq $GIT_TAG_RELEASE_VERSION) | ||
{ | ||
$GIT_TAG_LATEST = $GIT_TAG_RELEASE_VERSION | ||
} | ||
else | ||
{ | ||
$GIT_TAG_LATEST = @("v${GIT_TAG_RELEASE_VERSION}", "v${GIT_TAG_PRE_VERSION}-pre") | sort -Descending -Top 1 | ||
} | ||
echo "GIT_TAG_PRE_LATEST=$GIT_TAG_PRE_LATEST" >> $env:GITHUB_ENV | ||
echo "GIT_TAG_RELEASE_LATEST=$GIT_TAG_RELEASE_LATEST" >> $env:GITHUB_ENV | ||
echo "GIT_TAG_LATEST=$GIT_TAG_LATEST" >> $env:GITHUB_ENV | ||
echo "Latest Tag: $GIT_TAG_LATEST" | ||
|
||
echo "::set-output name=git-branch::$GIT_BRANCH" |
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,14 @@ | ||
# 配置构建信息 | ||
|
||
$BUILD_PATH = "$pwd\build" | ||
$PUBLISH_PATH = "$BUILD_PATH\publish" | ||
echo "BUILD_PATH=$BUILD_PATH" >> $Env:GITHUB_ENV | ||
echo "PUBLISH_PATH=$PUBLISH_PATH" >> $Env:GITHUB_ENV | ||
|
||
$BUILD_VERSION = (cat .\versioninfo.json | jq -r ".StringFileInfo.ProductVersion") | ||
echo "BUILD_VERSION=$BUILD_VERSION" >> $Env:GITHUB_ENV | ||
echo "Build Version: v$BUILD_VERSION" | ||
$GIT_TAG = "v$BUILD_VERSION$( ${env:GIT_BRANCH} -ne 'release' ? '-pre' : '' )" | ||
echo "GIT_TAG=$GIT_TAG" >> $Env:GITHUB_ENV | ||
echo "Current Tag: $GIT_TAG" | ||
echo "::set-output name=git-tag::$GIT_TAG" |
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,73 @@ | ||
# 构建前检查 | ||
|
||
$NOT_PASSED = 0 | ||
echo "Build Version: v${Env:BUILD_VERSION}`nCurrent Tag: ${Env:GIT_TAG}" | ||
echo "Latest Tag: ${Env:GIT_TAG_LATEST}`nLatest Release Tag: ${Env:GIT_TAG_RELEASE_LATEST}`nLatest Pre Tag: ${Env:GIT_TAG_PRE_LATEST}" | ||
|
||
if (!(${Env:GIT_TAG} -match ${Env:VERSION_REGEXP}) -or ${Env:GIT_TAG} -eq "") | ||
{ | ||
$NOT_PASSED = 1 | ||
echo "::error file=scripts/steps/build/3_checks.ps1,line=10,col=1::Cannot get the version information or it's incorrect." | ||
} | ||
if ($NOT_PASSED -eq 0) | ||
{ | ||
$INTERNAL_VERSION_REGEXP = "^(\d+\.\d+\.\d+)(\.\d+)?$" | ||
$fileVersion = (cat .\versioninfo.json | jq -r ".FixedFileInfo.FileVersion") | ||
$fileVersion = (echo $fileVersion | jq -r ".Major, .Minor, .Patch, .Build") -join "." | ||
$tmpVer = [regex]::Match($fileVersion, $INTERNAL_VERSION_REGEXP) | ||
if (!$tmpVer.success) | ||
{ | ||
$NOT_PASSED = 1 | ||
} | ||
else | ||
{ | ||
$fileVersion = $tmpVer.Groups[1].Value | ||
if ($tmpVer.Groups[2].Value -ne ".0") | ||
{ | ||
$fileVersion += $tmpVer.Groups[2].Value | ||
} | ||
} | ||
|
||
if ($NOT_PASSED -eq 0) | ||
{ | ||
$productVersion = (cat .\versioninfo.json | jq -r ".FixedFileInfo.ProductVersion") | ||
$productVersion = (echo $productVersion | jq -r ".Major, .Minor, .Patch, .Build") -join "." | ||
$tmpVer = [regex]::Match($productVersion, $INTERNAL_VERSION_REGEXP) | ||
if (!$tmpVer.success) | ||
{ | ||
$NOT_PASSED = 1 | ||
} | ||
else | ||
{ | ||
$productVersion = $tmpVer.Groups[1].Value | ||
if ($tmpVer.Groups[2].Value -ne ".0") | ||
{ | ||
$productVersion += $tmpVer.Groups[2].Value | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (($NOT_PASSED -eq 0) -and (($productVersion -ne $fileVersion) -or (${Env:BUILD_VERSION} -ne $productVersion))) | ||
{ | ||
$NOT_PASSED = 1 | ||
echo "::error file=scripts/steps/build/3_checks.ps1,line=54,col=1::The version information has some differences.`nPlease check `"versioninfo.json`"" | ||
} | ||
(git tag -l | where { $_ -eq "v0.1.3.21-pre" }).Count | ||
|
||
if (($NOT_PASSED -eq 0) -and (((git tag -l | where { $_ -eq ${Env:GIT_TAG} }).Count) -gt 0 -or | ||
(${Env:GIT_TAG_RELEASE_LATEST} -ne "" -and ${Env:GIT_TAG} -eq ${Env:GIT_TAG_RELEASE_LATEST}) -or | ||
(${Env:GIT_TAG_PRE_LATEST} -ne "" -and ${Env:GIT_TAG} -eq ${Env:GIT_TAG_PRE_LATEST}) -or | ||
(${Env:GIT_TAG_LATEST} -ne "" -and (${Env:GIT_TAG}.replace("-pre", "") -lt ${Env:GIT_TAG_LATEST}.replace("-pre", "") -or | ||
(${Env:GIT_TAG}.replace("-pre", "") -eq ${Env:GIT_TAG_LATEST}.replace("-pre", "") -and | ||
(${Env:GIT_TAG}.contains("-pre") -or !${Env:GIT_TAG_LATEST}.contains("-pre")))) | ||
))) | ||
{ | ||
$NOT_PASSED = 1 | ||
echo "::error file=scripts/steps/build/3_checks.ps1,line=67,col=1::A newer or the current version already exists." | ||
} | ||
if ($NOT_PASSED -ne 0) | ||
{ | ||
echo "::error file=scripts/steps/build/3_checks.ps1,line=71,col=1::Check the version information is not passed." | ||
exit 1 | ||
} |
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,11 @@ | ||
# 准备发布PreRelease文件 | ||
|
||
cd $env:BUILD_PATH | ||
mkdir -Force $env:PUBLISH_PATH | ||
$BUILD_X64_FILENAME = "Clash.Mini_${env:GIT_BRANCH}_v${env:BUILD_VERSION}_x64.exe" | ||
$BUILD_X86_FILENAME = "Clash.Mini_${env:GIT_BRANCH}_v${env:BUILD_VERSION}_x86.exe" | ||
echo "BUILD_X64_FILENAME=$BUILD_X64_FILENAME" >> $env:GITHUB_ENV | ||
echo "BUILD_X86_FILENAME=$BUILD_X86_FILENAME" >> $env:GITHUB_ENV | ||
cp .\Clash.Mini_*.exe $env:PUBLISH_PATH\ | ||
echo "Ready to upload the following file(s):" | ||
ls $env:PUBLISH_PATH |
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,16 @@ | ||
# 准备上传Artifact文件 | ||
|
||
cd $env:BUILD_PATH | ||
mkdir -Force $env:PUBLISH_PATH | ||
$BUILD_X64_FILENAME = "Clash.Mini_${env:GIT_BRANCH}_v${env:BUILD_VERSION}_${env:SHORT_SHA}_x64.exe" | ||
$BUILD_X86_FILENAME = "Clash.Mini_${env:GIT_BRANCH}_v${env:BUILD_VERSION}_${env:SHORT_SHA}_x86.exe" | ||
echo "BUILD_X64_FILENAME=$BUILD_X64_FILENAME" >> $env:GITHUB_ENV | ||
echo "BUILD_X86_FILENAME=$BUILD_X86_FILENAME" >> $env:GITHUB_ENV | ||
cp .\Clash.Mini_dev_x64.exe $env:PUBLISH_PATH\$BUILD_X64_FILENAME | ||
cp .\Clash.Mini_dev_x86.exe $env:PUBLISH_PATH\$BUILD_X86_FILENAME | ||
|
||
echo "Ready to upload the following file(s):" | ||
ls $env:PUBLISH_PATH | ||
|
||
echo "::set-output name=build-x64-filename::$BUILD_X64_FILENAME" | ||
echo "::set-output name=build-x86-filename::$BUILD_X86_FILENAME" |
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,6 @@ | ||
# 准备发布Release文件 | ||
|
||
cd $Env:BUILD_PATH | ||
cp .\Clash.Mini_*.exe ${Env:PUBLISH_PATH}\ | ||
echo "Ready to upload the following file(s):" | ||
ls ${Env:PUBLISH_PATH} |
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,36 @@ | ||
# 准备压缩 | ||
|
||
cd $env:BUILD_PATH | ||
mkdir -Force ($PUBLISH_PATH_X64 = "${env:PUBLISH_PATH}\x64") | ||
mkdir -Force ($PUBLISH_PATH_X86 = "${env:PUBLISH_PATH}\x86") | ||
echo "PUBLISH_PATH_X64=$PUBLISH_PATH_X64" >> $env:GITHUB_ENV | ||
echo "PUBLISH_PATH_X86=$PUBLISH_PATH_X86" >> $env:GITHUB_ENV | ||
mkdir -Force .\profile | ||
|
||
$packageFiles = @(".\profile", "..\config.yaml", "..\Country.mmdb") | ||
|
||
mv ${env:PUBLISH_PATH}\Clash.Mini*64.exe $PUBLISH_PATH_X64\Clash.Mini.exe | ||
$filesX64 = $packageFiles | ||
foreach ($file in $filesX64) | ||
{ | ||
cp $file $PUBLISH_PATH_X64\ | ||
} | ||
|
||
mv ${env:PUBLISH_PATH}\Clash.Mini*86.exe $PUBLISH_PATH_X86\Clash.Mini.exe | ||
$filesX86 = $packageFiles | ||
foreach ($file in $filesX86) | ||
{ | ||
cp $file $PUBLISH_PATH_X86\ | ||
} | ||
|
||
mkdir -Force ($RELEASE_PATH = "${env:PUBLISH_PATH}\releases") | ||
echo "RELEASE_PATH=$RELEASE_PATH" >> $env:GITHUB_ENV | ||
$RELEASE_PKG_X64 = "$RELEASE_PATH\Clash.Mini_${env:GIT_TAG}_x64.7z" | ||
$RELEASE_PKG_X86 = "$RELEASE_PATH\Clash.Mini_${env:GIT_TAG}_x86.7z" | ||
echo "RELEASE_PKG_X64=$RELEASE_PKG_X64" >> $env:GITHUB_ENV | ||
echo "RELEASE_PKG_X86=$RELEASE_PKG_X86" >> $env:GITHUB_ENV | ||
|
||
$RELEASE_PKG_X64 = $RELEASE_PKG_X64.Substring($RELEASE_PKG_X64.LastIndexOf("\") + 1) | ||
$RELEASE_PKG_X86 = $RELEASE_PKG_X86.Substring($RELEASE_PKG_X86.LastIndexOf("\") + 1) | ||
echo "::set-output name=release-pkg-x64::$RELEASE_PKG_X64" | ||
echo "::set-output name=release-pkg-x86::$RELEASE_PKG_X86" |
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,19 @@ | ||
# 推送到TG | ||
|
||
if [ -f "./RELEASELOG_NOTIFY.md" ]; then | ||
RELEASE_LOG="./RELEASELOG_NOTIFY.md" | ||
else | ||
RELEASE_LOG="./RELEASELOG.md" | ||
fi | ||
RLT=$(curl --location --request POST https://api.telegram.org/bot${TG_BOT_TOKEN}/sendMessage -s --form-string chat_id=${CHAT_ID} --form-string text="$(perl -lne 'print;' $RELEASE_LOG)" --form-string parse_mode="Markdown" --form-string disable_web_page_preview="true" --form-string allow_sending_without_reply="true" --form-string reply_markup="{\"inline_keyboard\":[[{\"text\":\"📦下载\",\"url\":\"https://github.com/Clash-Mini/Clash.Mini/releases/tag/${GIT_TAG}\"},{\"text\":\"⭐点个Star吧\",\"url\":\"https://github.com/Clash-Mini/Clash.Mini\"}]]}") | ||
IS_OK=$(echo $RLT | jq ".ok") | ||
echo $RLT | jq . | ||
if $IS_OK; then | ||
MSG_ID=$(echo $RLT | jq ".result.message_id") | ||
echo "::set-output name=push-msg-id::$MSG_ID" | ||
else | ||
echo "::error file=scripts/steps/notification/1_push_broadcast_tg.sh,line=15,col=1::push to channel failed." | ||
echo "Response: " | ||
echo "$RLT" | jq . | ||
exit 1 | ||
fi |
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,30 @@ | ||
# 推送到TG | ||
|
||
DT_STR=$(date "+%Y%m%d%H%M%S") | ||
PART_X64=$(echo "${DT_STR}_Clash.Mini_X64_${GITHUB_SHA}" | base64 | tr -s "=" 2) | ||
PART_X86=$(echo "${DT_STR}_Clash.Mini_X86_${GITHUB_SHA}" | base64 | tr -s "=" 2) | ||
|
||
RELEASE_URL="https://github.com/Clash-Mini/Clash.Mini/releases/download/${GIT_TAG}" | ||
echo "$RELEASE_URL" | ||
RELEASE_PATH="$(pwd)/releases" | ||
mkdir -p "$RELEASE_PATH" | ||
echo "${RELEASE_URL}/${RELEASE_PKG_X64}" | ||
echo "${RELEASE_URL}/${RELEASE_PKG_X86}" | ||
echo "${RELEASE_URL}/${RELEASE_PKG_X64}.sha256" | ||
echo "${RELEASE_URL}/${RELEASE_PKG_X86}.sha256" | ||
curl -L -o "${RELEASE_PATH}/${RELEASE_PKG_X64}" "${RELEASE_URL}/${RELEASE_PKG_X64}" | ||
curl -L -o "${RELEASE_PATH}/${RELEASE_PKG_X86}" "${RELEASE_URL}/${RELEASE_PKG_X86}" | ||
curl -L -o "${RELEASE_PATH}/${RELEASE_PKG_X64}.sha256" "${RELEASE_URL}/${RELEASE_PKG_X64}.sha256" | ||
curl -L -o "${RELEASE_PATH}/${RELEASE_PKG_X86}.sha256" "${RELEASE_URL}/${RELEASE_PKG_X86}.sha256" | ||
ls -lahR "$RELEASE_PATH" | ||
|
||
RELEASE_X64_SHA256=$(cat "${RELEASE_PATH}/${RELEASE_PKG_X64}.sha256" | tr -d "\n") | ||
RELEASE_X86_SHA256=$(cat "${RELEASE_PATH}/${RELEASE_PKG_X86}.sha256" | tr -d "\n") | ||
RLT=$(curl --location --request POST https://api.telegram.org/bot${TG_BOT_TOKEN}/sendMediaGroup -s --form-string chat_id=${CHAT_ID} --form-string reply_to_message_id=$PUSH_MSG_ID --form $PART_X64=@"${RELEASE_PATH}/${RELEASE_PKG_X64}" --form $PART_X86=@"${RELEASE_PATH}/${RELEASE_PKG_X86}" --form-string media="[{\"type\": \"document\",\"media\": \"attach://$PART_X64\",\"caption\": \"SHA256: ${RELEASE_X64_SHA256}\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://$PART_X86\",\"caption\": \"SHA256: ${RELEASE_X86_SHA256}\",\"parse_mode\": \"Markdown\"}]") | ||
IS_OK=$(echo "$RLT" | jq ".ok") | ||
if ! $IS_OK; then | ||
echo "::error file=scripts/steps/notification/2_push_files_tg.sh,line=26,col=1::pushing files to channel failed." | ||
echo "Response: " | ||
echo "$RLT" | jq . | ||
exit 1 | ||
fi |
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,23 @@ | ||
# 推送到TG | ||
|
||
DT_STR=$(date "+%Y%m%d%H%M%S") | ||
PART_X64=$(echo "${DT_STR}_Clash.Mini_X64_${GITHUB_SHA}" | base64 | tr -s "=" 2) | ||
PART_X86=$(echo "${DT_STR}_Clash.Mini_X86_${GITHUB_SHA}" | base64 | tr -s "=" 2) | ||
|
||
RUNNER_URL="https://github.com/JyCyunMe/Clash.Mini/actions/runs/${GITHUB_RUN_ID}" | ||
echo "$RUNNER_URL" | ||
ls -lahR "$ARTIFACTS_PATH" | ||
ARTIFACT_X64="${ARTIFACTS_PATH}/${BUILD_X64_FILENAME}" | ||
ARTIFACT_X86="${ARTIFACTS_PATH}/${BUILD_X86_FILENAME}" | ||
|
||
ARTIFACT_X64_SHA256=$(cat "${ARTIFACT_X64}.sha256/${BUILD_X64_FILENAME}.sha256" | tr -d "\n") | ||
ARTIFACT_X86_SHA256=$(cat "${ARTIFACT_X86}.sha256/${BUILD_X86_FILENAME}.sha256" | tr -d "\n") | ||
RLT=$(curl --location --request POST https://api.telegram.org/bot${TG_BOT_TOKEN}/sendMediaGroup -s --form-string chat_id=${UPLOAD_CHAT_ID} --form "$PART_X64=@\"${ARTIFACT_X64}/${BUILD_X64_FILENAME}\"" --form "$PART_X86=@\"${ARTIFACT_X86}/${BUILD_X86_FILENAME}\"" --form-string media="[{\"type\": \"document\",\"media\": \"attach://$PART_X64\",\"caption\": \"SHA256: ${ARTIFACT_X64_SHA256}\",\"parse_mode\": \"MarkdownV2\"},{\"type\": \"document\",\"media\": \"attach://$PART_X86\",\"caption\": \"SHA256: ${ARTIFACT_X86_SHA256}\n\n_[${GITHUB_WORKFLOW} \\\\#${GITHUB_RUN_NUMBER}](${RUNNER_URL})_\",\"parse_mode\": \"MarkdownV2\"}]") | ||
IS_OK=$(echo $RLT | jq ".ok") | ||
echo $RLT | jq . | ||
if ! $IS_OK; then | ||
echo "::error file=scripts/steps/notification/2_push_files_tg_dev.sh,line=19,col=1::pushing files to channel failed." | ||
echo "Response: " | ||
echo $RLT | jq . | ||
exit 1 | ||
fi |
Oops, something went wrong.