Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

让工作流编译支持替换 client_id 和 x-api-key #4228

Merged
merged 50 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
678fc3b
Update build.yml
allMagicNB Jul 11, 2024
3c71a2c
更新 build.yml
allMagicNB Jul 11, 2024
4747c3d
更新 build.yml
allMagicNB Jul 11, 2024
e0bd274
更新 build.yml
allMagicNB Jul 11, 2024
59a05a8
Merge branch 'Hex-Dragon:main' into main
allMagicNB Jul 11, 2024
d49a8f8
Fix & + .gitignore & + Headers("x-api-key")
allMagicNB Jul 11, 2024
4358058
更换语气,让 “应该做” 变成 “可以做”。
allMagicNB Jul 11, 2024
2b55ed0
Update .gitignore
allMagicNB Jul 11, 2024
eaebd04
Merge branch 'Hex-Dragon:main' into main
allMagicNB Jul 11, 2024
8423ef6
Merge branch 'Hex-Dragon:main' into main
allMagicNB Jul 12, 2024
c860ad2
[no ci]Update build.yml
allMagicNB Jul 12, 2024
a7a4838
[no ci]Update build.yml
allMagicNB Jul 12, 2024
d52a4ec
Update build.yml
allMagicNB Jul 12, 2024
ecf1fae
Merge branch 'Hex-Dragon:main' into main
allMagicNB Jul 15, 2024
b10fc8c
Fix something
allMagicNB Jul 17, 2024
d7e649c
Fix Replace
allMagicNB Jul 17, 2024
2348d3c
+ env
allMagicNB Jul 17, 2024
83a5370
更新 build.yml
allMagicNB Jul 17, 2024
227cecc
- .zip
allMagicNB Jul 17, 2024
cc18004
更新 build.yml
allMagicNB Jul 17, 2024
15f82f1
更新 build.yml
allMagicNB Jul 17, 2024
fa9e1be
更新 build.yml
allMagicNB Jul 17, 2024
1bd7b71
- dir
allMagicNB Jul 17, 2024
7cf91d9
del Release
allMagicNB Jul 20, 2024
2b57e1e
Merge branch 'main' of https://github.com/allMagicNB/PCL2
allMagicNB Jul 20, 2024
7be16a8
Merge branch 'Hex-Dragon:main' into main
allMagicNB Aug 3, 2024
3f332fe
X_API_KEY -> CURSEFORGE_API_KEY
allMagicNB Aug 3, 2024
1519c90
Merge branch 'Hex-Dragon:main' into main
allMagicNB Aug 13, 2024
f919ae4
Merge branch 'Hex-Dragon:main' into main
allMagicNB Aug 14, 2024
b6a06f8
更新 build.yml
allMagicNB Aug 20, 2024
26c492b
更新 build.yml
allMagicNB Aug 20, 2024
2bdda57
更新 build.yml
allMagicNB Aug 20, 2024
68c1deb
Merge branch 'main' into main
allMagicNB Aug 27, 2024
5ea5dc3
Fix Replace client_id
allMagicNB Aug 27, 2024
c917066
+ Const
allMagicNB Aug 30, 2024
6b041cd
Update .github/workflows/build.yml
allMagicNB Aug 30, 2024
d390ce0
Update Plain Craft Launcher 2/Modules/ModSecret.vb
allMagicNB Aug 30, 2024
9ed5f04
Update Plain Craft Launcher 2/Modules/ModSecret.vb
allMagicNB Aug 30, 2024
e32bc28
漏个单引号
allMagicNB Aug 30, 2024
0d47b82
+ CommitHash
allMagicNB Aug 31, 2024
9fb4561
更新 Application.xaml.vb
allMagicNB Aug 31, 2024
58ad193
更新 Application.xaml.vb
allMagicNB Aug 31, 2024
4d28be2
更新 ModBase.vb
allMagicNB Aug 31, 2024
dff5b47
Merge branch 'main' into main
allMagicNB Aug 31, 2024
ae503a6
更新 build.yml
allMagicNB Aug 31, 2024
5bf3ce0
Update Plain Craft Launcher 2/Application.xaml.vb
allMagicNB Aug 31, 2024
b30ad60
Update Plain Craft Launcher 2/Modules/Base/ModBase.vb
allMagicNB Sep 3, 2024
e51f6f0
Update .github/workflows/build.yml
allMagicNB Sep 3, 2024
8e03681
更新 build.yml
allMagicNB Sep 23, 2024
2dfa810
Merge branch 'main' into main
LTCatt Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Build

on:
push:
paths:
Expand All @@ -12,37 +11,34 @@ on:
workflow_dispatch:

jobs:

build:

strategy:
matrix:
configuration: [Debug, Release, Snapshot, BETA, ReleaseUpdate]

name: Build
runs-on: windows-latest

env:
configuration: Debug
allMagicNB marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set Describe
shell: bash
run: |
Describe=`git describe --tags --always`
echo "Describe=$Describe" >> $GITHUB_ENV

describe=`git describe --tags --always`
echo "describe=$describe" >> $GITHUB_ENV
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64

- name: Replace
run: |
(gc "Plain Craft Launcher 2\Modules\ModSecret.vb") -replace 'Public Const OAuthClientId As String = ""', 'Public Const OAuthClientId As String = "${{ secrets.CLIENT_ID }}"' | Out-File "Plain Craft Launcher 2\Modules\ModSecret.vb"
(gc "Plain Craft Launcher 2\Modules\ModSecret.vb") -replace 'Public Const CurseForgeAPIKey As String = ""', 'Public Const CurseForgeAPIKey As String = "${{ secrets.CURSEFORGE_API_KEY }}"' | Out-File "Plain Craft Launcher 2\Modules\ModSecret.vb"
(gc "Plain Craft Launcher 2\Modules\Base\ModBase.vb") -replace 'Public Const CommitHash As String = ""', 'Public Const CommitHash As String = "${{ github.sha }}"' | Out-File "Plain Craft Launcher 2\Modules\Base\ModBase.vb"
- name: Build
run: msbuild "Plain Craft Launcher 2\Plain Craft Launcher 2.vbproj" -p:Configuration=${{ matrix.configuration }}

run: msbuild "Plain Craft Launcher 2\Plain Craft Launcher 2.vbproj" -p:Configuration=${{ env.configuration }}
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.configuration }} ${{ env.Describe }}
path: Plain Craft Launcher 2\obj\${{ matrix.configuration }}\Plain Craft Launcher 2.exe
name: ${{ env.configuration }} ${{ env.describe }}
path: Plain Craft Launcher 2\obj\Debug\Plain Craft Launcher 2.exe
allMagicNB marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion Plain Craft Launcher 2/Application.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Public Class Application
'日志初始化
LogStart()
'添加日志
Log($"[Start] 程序版本:{VersionDisplayName} ({VersionCode})")
Log($"[Start] 程序版本:{VersionDisplayName} ({VersionCode}){If(CommitHash <> "", $",Commit Hash:{CommitHash}", "")}")
Log($"[Start] 识别码:{UniqueAddress}{If(ThemeCheckOne(9), ",已解锁反馈主题", "")}")
Log($"[Start] 程序路径:{PathWithName}")
Log($"[Start] 系统编码:{Encoding.Default} ({Encoding.Default.CodePage}, GBK={IsGBKEncoding})")
Expand Down
2 changes: 2 additions & 0 deletions Plain Craft Launcher 2/Modules/Base/ModBase.vb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Public Module ModBase
'下列版本信息由更新器自动修改
Public Const VersionBaseName As String = "2.8.5" '不含分支前缀的显示用版本名
Public Const VersionStandardCode As String = "2.8.5." & VersionBranchCode '标准格式的四段式版本号
'CommitHash
Public Const CommitHash As String = ""
allMagicNB marked this conversation as resolved.
Show resolved Hide resolved
#If BETA Then
Public Const VersionCode As Integer = 332 'Release
#Else
Expand Down
8 changes: 5 additions & 3 deletions Plain Craft Launcher 2/Modules/ModSecret.vb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Friend Module ModSecret
Public Const RegFolder As String = "PCLDebug"
'用于微软登录的 ClientId
Public Const OAuthClientId As String = ""
'CurseForge API Key
Public Const CurseForgeAPIKey As String = ""

Friend Sub SecretOnApplicationStart()
'提升 UI 线程优先级
Expand Down Expand Up @@ -44,7 +46,7 @@ Friend Module ModSecret
End If
'开源版本提示
MyMsgBox($"该版本中无法使用以下特性:
- CurseForge API 调用:需要你自行申请 API Key,然后添加到 SecretHeadersSign 方法中
- CurseForge API 调用:需要你自行申请 API Key,然后添加到 ModSecret.vb 的开头
- 正版登录:需要你自行申请 Client ID,然后添加到 ModSecret.vb 的开头
- 更新与联网通知:避免滥用隐患
- 主题切换:这是需要赞助解锁的纪念性质的功能,别让赞助者太伤心啦……
Expand Down Expand Up @@ -107,7 +109,7 @@ Friend Module ModSecret
Client.Headers("User-Agent") = "PCL2/" & VersionStandardCode
End If
Client.Headers("Referer") = "http://" & VersionCode & ".pcl2.open.server/"
'如果你有 CurseForge API Key,请添加到 Headers 中,以恢复对 CurseForge 的访问
Client.Headers("x-api-key") = CurseForgeAPIKey
End Sub
''' <summary>
''' 设置 Headers 的 UA、Referer。
Expand All @@ -121,7 +123,7 @@ Friend Module ModSecret
Request.UserAgent = "PCL2/" & VersionStandardCode
End If
Request.Referer = "http://" & VersionCode & ".pcl2.open.server/"
'如果你有 CurseForge API Key,请添加到 Headers 中,以恢复对 CurseForge 的访问
Request.Headers("x-api-key") = CurseForgeAPIKey
End Sub

#End Region
Expand Down