From e67a688baa5c6a0a6ea7b331280ee25dcb2b50b5 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Mon, 3 Mar 2025 02:02:06 +0100 Subject: [PATCH] Building with Github Actions --- .github/dev.yml | 9 ++++-- .github/workflows/autolock.yml | 2 +- .github/workflows/dev.yml | 53 ++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 56 ++++++++++++++++++++++++++++++++++ src/Client.cs | 1 + src/TlsStream.cs | 6 ++-- src/WTelegramClient.csproj | 4 +-- 7 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/dev.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/dev.yml b/.github/dev.yml index e8a3729..6206e8e 100644 --- a/.github/dev.yml +++ b/.github/dev.yml @@ -1,7 +1,11 @@ 锘縫r: none -trigger: [ master ] +trigger: + branches: + include: [ master ] + paths: + exclude: [ '.github', '*.md', 'Examples' ] -name: 4.3.1-dev.$(Rev:r) +name: 4.3.2-dev.$(Rev:r) pool: vmImage: ubuntu-latest @@ -57,4 +61,3 @@ stages: "message": "{ \"commitId\": \"$(Build.SourceVersion)\", \"buildNumber\": \"$(Build.BuildNumber)\", \"teamProjectName\": \"$(System.TeamProject)\", \"commitMessage\": \"$(Release_Notes)\" }" } waitForCompletion: 'false' - \ No newline at end of file diff --git a/.github/workflows/autolock.yml b/.github/workflows/autolock.yml index 0bd8a20..9a676bc 100644 --- a/.github/workflows/autolock.yml +++ b/.github/workflows/autolock.yml @@ -2,7 +2,7 @@ name: 'Auto-Lock Issues' on: schedule: - - cron: '17 2 * * *' + - cron: '17 2 * * 1' workflow_dispatch: permissions: diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..6130d21 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,53 @@ +name: Dev build + +on: + push: + branches: [ master ] + paths-ignore: [ '.**', 'Examples/**', '**.md' ] + +env: + PROJECT_PATH: src/WTelegramClient.csproj + CONFIGURATION: Release + RELEASE_NOTES: ${{ github.event.head_commit.message }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 100 + - name: Determine version + run: | + git fetch --depth=100 --tags + DESCR_TAG=$(git describe --tags) + COMMITS=${DESCR_TAG#*-} + COMMITS=${COMMITS%-*} + LAST_TAG=${DESCR_TAG%%-*} + NEXT_VERSION=${LAST_TAG%.*}.$((${LAST_TAG##*.} + 1))-dev.$COMMITS + RELEASE_VERSION=${{vars.RELEASE_VERSION}}-dev.$COMMITS + if [[ "$RELEASE_VERSION" > "$NEXT_VERSION" ]] then VERSION=$RELEASE_VERSION; else VERSION=$NEXT_VERSION; fi + echo Last tag: $LAST_TAG 路 Next version: $NEXT_VERSION 路 Release version: $RELEASE_VERSION 路 Build version: $VERSION + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Pack + run: dotnet pack $PROJECT_PATH --configuration $CONFIGURATION -p:Version=$VERSION "-p:ReleaseNotes=\"$RELEASE_NOTES\"" --output packages + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: packages + # path: packages/*.nupkg + - name: Nuget push + run: dotnet nuget push packages/*.nupkg --api-key ${{secrets.NUGETAPIKEY}} --skip-duplicate --source https://api.nuget.org/v3/index.json + - name: Deployment Notification + env: + JSON: | + { + "status": "success", "complete": true, "commitMessage": ${{ toJSON(github.event.head_commit.message) }}, + "message": "{ \"commitId\": \"${{ github.event.head_commit.id }}\", \"buildNumber\": \"${{ env.VERSION }}\", \"teamProjectName\": \"${{ github.event.repository.name }}\"}" + } + run: | + curl -X POST -H "Content-Type: application/json" -d "$JSON" ${{ secrets.DEPLOYED_WEBHOOK }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5d1519e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: Release build + +on: + workflow_dispatch: + inputs: + release_notes: + description: 'Release notes' + required: true + version: + description: "Release version (leave empty for automatic versioning)" + +run-name: '馃搶 Release build ${{ inputs.version }}' + +env: + PROJECT_PATH: src/WTelegramClient.csproj + CONFIGURATION: Release + RELEASE_NOTES: ${{ inputs.release_notes }} + VERSION: ${{ inputs.version }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write # For git tag + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 100 + - name: Determine version + if: ${{ env.VERSION == '' }} + run: | + git fetch --depth=100 --tags + DESCR_TAG=$(git describe --tags) + LAST_TAG=${DESCR_TAG%%-*} + NEXT_VERSION=${LAST_TAG%.*}.$((${LAST_TAG##*.} + 1)) + RELEASE_VERSION=${{vars.RELEASE_VERSION}} + if [[ "$RELEASE_VERSION" > "$NEXT_VERSION" ]] then VERSION=$RELEASE_VERSION; else VERSION=$NEXT_VERSION; fi + echo Last tag: $LAST_TAG 路 Next version: $NEXT_VERSION 路 Release version: $RELEASE_VERSION 路 Build version: $VERSION + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Pack + run: dotnet pack $PROJECT_PATH --configuration $CONFIGURATION -p:Version=$VERSION "-p:ReleaseNotes=\"$RELEASE_NOTES\"" --output packages + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: packages + # path: packages/*.nupkg + - name: Nuget push + run: dotnet nuget push packages/*.nupkg --api-key ${{secrets.NUGETAPIKEY}} --skip-duplicate --source https://api.nuget.org/v3/index.json + - name: Git tag + run: | + git tag $VERSION + git push --tags diff --git a/src/Client.cs b/src/Client.cs index fead981..fa172e6 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -292,6 +292,7 @@ namespace WTelegram /// ID of the Data Center (use negative values for media_only) /// Connect immediately /// Client connected to the selected DC + /// 鈿狅笍 You shouldn't have to use this method unless you know what you're doing public async Task GetClientForDC(int dcId, bool connect = true) { if (_dcSession.DataCenter?.id == dcId) return this; diff --git a/src/TlsStream.cs b/src/TlsStream.cs index 3adc277..4e6ff30 100644 --- a/src/TlsStream.cs +++ b/src/TlsStream.cs @@ -100,7 +100,7 @@ namespace WTelegram static readonly byte[] TlsClientHello3 = [ // 0x00, 0x00, len { len { 0x00 len { domain } } } len is 16-bit big-endian length of the following block of data 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x08, 0x4A, 0x4A,/*=grease(4)*/ 0x00, 0x1d, 0x00, 0x17, 0x00, 0x18, + 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x08, 0x4A, 0x4A/*=grease(4)*/, 0x00, 0x1d, 0x00, 0x17, 0x00, 0x18, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, 0x0d, 0x00, 0x12, 0x00, 0x10, 0x04, 0x03, 0x08, 0x04, 0x04, 0x01, 0x05, 0x03, 0x08, 0x05, 0x05, 0x01, 0x08, 0x06, 0x06, 0x01, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x0c, 0x02, 0x68, 0x32, 0x08, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31, @@ -108,9 +108,9 @@ namespace WTelegram 0x00, 0x17, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x02, 0x00, 0x02, 0x00, 0x23, 0x00, 0x00, - 0x00, 0x2b, 0x00, 0x07, 0x06, 0x6A, 0x6A,/*=grease(6) */ 0x03, 0x04, 0x03, 0x03, + 0x00, 0x2b, 0x00, 0x07, 0x06, 0x6A, 0x6A/*=grease(6)*/, 0x03, 0x04, 0x03, 0x03, 0x00, 0x2d, 0x00, 0x02, 0x01, 0x01, - 0x00, 0x33, 0x00, 0x2b, 0x00, 0x29, 0x4A, 0x4A,/*=grease(4) */ 0x00, 0x01, 0x00, 0x00, 0x1d, 0x00, 0x20, /* random[32] */ + 0x00, 0x33, 0x00, 0x2b, 0x00, 0x29, 0x4A, 0x4A/*=grease(4)*/, 0x00, 0x01, 0x00, 0x00, 0x1d, 0x00, 0x20, /* random[32] */ 0x44, 0x69, 0x00, 0x05, 0x00, 0x03, 0x02, 0x68, 0x32, 0xff, 0x01, 0x00, 0x01, 0x00, ]; diff --git a/src/WTelegramClient.csproj b/src/WTelegramClient.csproj index 79692c1..b54e320 100644 --- a/src/WTelegramClient.csproj +++ b/src/WTelegramClient.csproj @@ -33,8 +33,8 @@ $(ReleaseNotes.Replace("|", "%0D%0A").Replace(" - ","%0D%0A- ").Replace(" ", "% - - + +