From c1817a7282d861bfef5e9b427a7c8d6da9e474fe Mon Sep 17 00:00:00 2001 From: guqing <38999863+guqing@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:01:23 +0800 Subject: [PATCH] chore: update workflows config (#20) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What this PR does? 更新 workflows 配置 ```release-note None ``` --- .github/workflows/cd.yaml | 19 ++++++ .github/workflows/ci.yaml | 15 +++++ .github/workflows/workflow.yaml | 114 -------------------------------- src/main/resources/plugin.yaml | 2 + 4 files changed, 36 insertions(+), 114 deletions(-) create mode 100644 .github/workflows/cd.yaml create mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/workflow.yaml diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..0e5071d --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,19 @@ +name: CD + +on: + release: + types: + - published + +jobs: + cd: + uses: halo-sigs/reusable-workflows/.github/workflows/plugin-cd.yaml@v1 + secrets: + halo-username: ${{ secrets.HALO_USERNAME }} + halo-password: ${{ secrets.HALO_PASSWORD }} + permissions: + contents: write + with: + app-id: app-sqpgf + skip-node-setup: true + diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..6efa4de --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,15 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + ci: + uses: halo-sigs/reusable-workflows/.github/workflows/plugin-ci.yaml@v1 + with: + skip-node-setup: true diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml deleted file mode 100644 index 4b88561..0000000 --- a/.github/workflows/workflow.yaml +++ /dev/null @@ -1,114 +0,0 @@ -name: Build Plugin JAR File - -on: - push: - branches: - - main - paths: - - "**" - - "!**.md" - release: - types: - - created - pull_request: - branches: - - main - paths: - - "**" - - "!**.md" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - distribution: 'temurin' - cache: 'gradle' - java-version: 17 - - name: Build with Gradle - run: | - # Set the version with tag name when releasing - version=${{ github.event.release.tag_name }} - version=${version#v} - sed -i "s/version=.*-SNAPSHOT$/version=$version/1" gradle.properties - ./gradlew clean build -x test - - name: Archive plugin-highlightjs jar - uses: actions/upload-artifact@v2 - with: - name: plugin-highlightjs - path: | - build/libs/*.jar - retention-days: 1 - - github-release: - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'release' - steps: - - name: Download plugin-highlightjs jar - uses: actions/download-artifact@v2 - with: - name: plugin-highlightjs - path: build/libs - - name: Get Name of Artifact - id: get_artifact - run: | - ARTIFACT_PATHNAME=$(ls build/libs/*.jar | head -n 1) - ARTIFACT_NAME=$(basename ${ARTIFACT_PATHNAME}) - echo "Artifact pathname: ${ARTIFACT_PATHNAME}" - echo "Artifact name: ${ARTIFACT_NAME}" - echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV - echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV - echo "RELEASE_ID=${{ github.event.release.id }}" >> $GITHUB_ENV - - name: Upload a Release Asset - uses: actions/github-script@v2 - if: github.event_name == 'release' - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - console.log('environment', process.versions); - - const fs = require('fs').promises; - - const { repo: { owner, repo }, sha } = context; - console.log({ owner, repo, sha }); - - const releaseId = process.env.RELEASE_ID - const artifactPathName = process.env.ARTIFACT_PATHNAME - const artifactName = process.env.ARTIFACT_NAME - console.log('Releasing', releaseId, artifactPathName, artifactName) - - await github.repos.uploadReleaseAsset({ - owner, repo, - release_id: releaseId, - name: artifactName, - data: await fs.readFile(artifactPathName) - }); - - app-store-release: - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'release' - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Download plugin-highlightjs jar - uses: actions/download-artifact@v2 - with: - name: plugin-highlightjs - path: build/libs - - name: Sync to Halo App Store - uses: halo-sigs/app-store-release-action@main - with: - github-token: ${{secrets.GITHUB_TOKEN}} - app-id: ${{secrets.APP_ID}} - release-id: ${{ github.event.release.id }} - assets-dir: "build/libs" - halo-username: ${{ secrets.HALO_USERNAME }} - halo-password: ${{ secrets.HALO_PASSWORD }} diff --git a/src/main/resources/plugin.yaml b/src/main/resources/plugin.yaml index b0ebf5f..b5ef421 100644 --- a/src/main/resources/plugin.yaml +++ b/src/main/resources/plugin.yaml @@ -2,6 +2,8 @@ apiVersion: plugin.halo.run/v1alpha1 kind: Plugin metadata: name: PluginHighlightJS + annotations: + store.halo.run/app-id: app-sqpgf spec: enabled: true version: 1.0.0