From 62b809c57a79ad129c241666fff084bcd4370f63 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Mon, 22 Jan 2024 16:29:09 -0500 Subject: [PATCH] WIP Workshop update checker This (should) add a static file to the Workshop version only that contains the current commit hash before the upload process, which is then used to check for updates like normal. Haven't been able to test this from start to finish yet, but we'll see how it goes once everything is ready for release. --- .github/workflows/workshop-upload.yml | 38 +++++++++++++++++++++++++++ lua/acf/core/version/version_sh.lua | 8 ++++++ 2 files changed, 46 insertions(+) create mode 100644 .github/workflows/workshop-upload.yml diff --git a/.github/workflows/workshop-upload.yml b/.github/workflows/workshop-upload.yml new file mode 100644 index 000000000..7daaa8af3 --- /dev/null +++ b/.github/workflows/workshop-upload.yml @@ -0,0 +1,38 @@ +name: Deploy to Workshop + +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + deploy: + if: github.repository == 'ACF-Team/ACF-3' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Create Commit Version File + shell: bash + run: | + mkdir data_static + mkdir data_static/acf + cat > data_static/acf/acf-3-version.txt + ${{ github.sha }} + EOF + + - name: Upload to Workshop + uses: CFC-Servers/gmod-upload@master + with: + id: whatever the ID ends up being + changelog: "${{ github.event.head_commit.message }}" + title: "[ACF-3] Armored Combat Framework" + type: "tool" + tag1: "build" + tag2: "fun" + tag3: "realism" + env: + STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }} + STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }} \ No newline at end of file diff --git a/lua/acf/core/version/version_sh.lua b/lua/acf/core/version/version_sh.lua index 3c8e33d68..76fa48e04 100644 --- a/lua/acf/core/version/version_sh.lua +++ b/lua/acf/core/version/version_sh.lua @@ -65,6 +65,7 @@ do -- Local repository version checking if not Data then return end local Path = Data.Path + local WorkshopPath = "data_static/acf/" .. string.lower(Name) .. "-version.txt" if not Path then Data.Code = "Not Installed" @@ -77,6 +78,13 @@ do -- Local repository version checking Data.Code = "Git-" .. Code Data.Date = LocalToUTC(Date) + elseif file.Exists(WorkshopPath, "GAME") then + local FileData = file.Read(WorkshopPath, "GAME"):Trim() + local Code = string.sub(FileData, 1, 7) + local Date = file.Time(WorkshopPath, "GAME") + + Data.Code = "Workshop-" .. Code + Data.Date = LocalToUTC(Date) elseif file.Exists(Path .. "/LICENSE", "GAME") then local Date = file.Time(Path .. "/LICENSE", "GAME")