Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
way-zer committed Sep 17, 2024
1 parent d6993f7 commit d428459
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
19 changes: 12 additions & 7 deletions .github/actions/clearOldAssets.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import * as core from "@actions/core"
import {context, getOctokit} from "@actions/github"
import {getOctokit} from "@actions/github"

const octokit = getOctokit(import.meta.env.GITHUB_TOKEN) as import("@octokit/plugin-rest-endpoint-methods/dist-types/types").Api
const selfBuild = import.meta.env.RELEASE_VERSION
const octokit = getOctokit(import.meta.env.TOKEN!) as import("@octokit/plugin-rest-endpoint-methods/dist-types/types").Api

async function clearOldAssets(tag: string, keep: number = 9) {
const [owner, repo] = import.meta.env.REPOSITORY!.split("/")
const tag = core.getInput("release") || import.meta.env.TAG!
const selfBuild = import.meta.env.RELEASE_VERSION!
console.log(owner, repo, tag, selfBuild)


async function clearOldAssets(keep: number = 9) {
const release = await octokit.rest.repos.getReleaseByTag({
...context.repo, tag
owner, repo, tag
})
const assets = release.data.assets.sort((a, b) => a.name < b.name ? 1 : -1)
if (assets.length <= keep) return
Expand All @@ -15,9 +20,9 @@ async function clearOldAssets(tag: string, keep: number = 9) {
console.log("ToRemove", toRemove.map(it => it.name))
await Promise.all(toRemove.map(it =>
octokit.rest.repos.deleteReleaseAsset({
...context.repo, asset_id: it.id
owner, repo, asset_id: it.id
})
))
}

await clearOldAssets(core.getInput("release") || import.meta.env.TAG)
await clearOldAssets()
11 changes: 7 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ jobs:
build-scan-terms-of-use-agree: "yes"
- name: Set env
run: |
git config --global user.email "[email protected]"
git config --global user.name "github_actions"
echo "RELEASE_TAG=${GITHUB_REF_NAME}-build" >> $GITHUB_ENV
echo "RELEASE_TAG=${GITHUB_REF_NAME}-build"
echo "RELEASE_VERSION=$(date +'%Y.%m.%d').X${GITHUB_RUN_NUMBER}-${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "${{ secrets.KEYSTORE_BASE64 }}" | openssl enc -d -base64 -in - -out ../bekeystore.jks
echo "${{ secrets.KEYSTORE_BASE64 }}" | openssl enc -d -base64 -in - -out bekeystore.jks
- name: Build
run: |
git submodule update --init --depth=10
cd work
../scripts/applyPatches
../scripts/applyPatches.sh
gradle desktop:dist server:dist -Pbuildversion=${RELEASE_VERSION}
cd ..
Expand Down Expand Up @@ -74,6 +77,6 @@ jobs:
- name: clearOldAssets
run: bun run .github/actions/clearOldAssets.ts
env:
GITHUB_TOKEN: ${{secrets.PUBLISH_TOKEN}}
GITHUB_REPOSITORY: TinyLake/MindustryX-work
TOKEN: ${{secrets.PUBLISH_TOKEN}}
REPOSITORY: TinyLake/MindustryX-work
TAG: ${{ env.RELEASE_TAG }}
2 changes: 1 addition & 1 deletion jitpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ install:
# - cd work/ && git fetch origin v145.1 && git reset --hard FETCH_HEAD && cd ..
- git config --global user.email "[email protected]"
- git config --global user.name "jitpack"
- sh ./scripts/applyPatches.sh && cd work/
- cd work/ && sh ../scripts/applyPatches.sh
- ./gradlew publishToMavenLocal
- echo -n > gradle.properties #zero out gradle.properties

0 comments on commit d428459

Please sign in to comment.