From b483630ea5f9489354a7c166c66ca268c1774ccf Mon Sep 17 00:00:00 2001 From: V <104217168+V-Official-233@users.noreply.github.com> Date: Sun, 10 Dec 2023 15:37:58 +0800 Subject: [PATCH] Create Build-halo.yaml (#5) --- .github/workflows/Build-halo.yaml | 94 +++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/Build-halo.yaml diff --git a/.github/workflows/Build-halo.yaml b/.github/workflows/Build-halo.yaml new file mode 100644 index 0000000..a464513 --- /dev/null +++ b/.github/workflows/Build-halo.yaml @@ -0,0 +1,94 @@ +name: Build Halo Fat Jar +on: + push: + branches: + - main + schedule: + - cron: '30 15 * * *' + - cron: '30 5 * * *' +jobs: + halo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: halo-dev/halo + fetch-depth: '0' + fetch-tags: 'true' + - name: 'Get Previous tag' + id: tag + uses: "WyriHaximus/github-action-get-previous-tag@v1" + with: + prefix: 'v' + - name: check release + id: check + run: | + echo ${{ steps.tag.outputs.tag }} + VAR=$(echo "${{ steps.tag.outputs.tag }}" | sed 's/v//') + echo $VAR + RELEASES=$(curl -s "https://api.github.com/repos/Lu7fer/Jar4Halo/releases/tags/${{ steps.tag.outputs.tag }}") + if echo "$RELEASES" | jq '.assets[].name' | grep -q "$VAR"; then + echo "check=0" >> $GITHUB_OUTPUT + else + echo "check=1" >> $GITHUB_OUTPUT + if curl -s "https://api.github.com/repos/halo-dev/halo/releases/tags/${{ steps.tag.outputs.tag }}" | jq '.prerelease' | grep -q "true"; then + echo "prerelease=true" >> $GITHUB_OUTPUT + else + echo "prerelease=false" >> $GITHUB_OUTPUT + fi + fi + - name: print var + run: | + echo check=${{ steps.check.outputs.check }} + echo tag=${{ steps.tag.outputs.tag }} + - uses: actions/checkout@v4 + if: ${{ steps.check.outputs.check != 0 }} + with: + repository: halo-dev/halo + ref: ${{ steps.tag.outputs.tag }} + - name: set version + id: ver + if: ${{ steps.check.outputs.check != 0 }} + run: | + echo "version=${{ steps.tag.outputs.tag }}" | sed 's/=v/=/' > gradle.properties + cat gradle.properties >> $GITHUB_OUTPUT + cat gradle.properties + curl -s "https://api.github.com/repos/halo-dev/halo/releases/tags/${{ steps.tag.outputs.tag }}" | jq -r '.body' > body.txt + - uses: actions/setup-java@v3 + if: ${{ steps.check.outputs.check != 0 }} + with: + distribution: 'temurin' + java-version: '17' + - uses: actions/setup-node@v3 + with: + node-version: '18' + if: ${{ steps.check.outputs.check != 0 }} + - name: gen resources + if: ${{ steps.check.outputs.check != 0 }} + run: | + cd console + npm install -g pnpm + pnpm install --no-frozen-lockfile + pnpm build:packages + pnpm build + # - name: Read value from Properties-file + # id: property + # uses: christian-draeger/read-properties@1.1.0 + # with: + # path: './halo/gradle.properties' + # properties: 'version' + - name: build + if: ${{ steps.check.outputs.check != 0 }} + run: | + ./gradlew clean build -x check + ls -lah application/build/libs + - name: Release + uses: softprops/action-gh-release@v1 + if: ${{ steps.check.outputs.check != 0 }} + with: + body_path: body.txt + prerelease: ${{ steps.check.outputs.prerelease }} + name: ${{ steps.ver.outputs.version }} + tag_name: ${{ steps.tag.outputs.tag }} + token: ${{ secrets.TOKEN }} + files: application/build/libs/application-${{ steps.ver.outputs.version }}.jar