Skip to content

Commit 5f92899

Browse files
committed
chore: update github action
1 parent 9426ec6 commit 5f92899

File tree

2 files changed

+105
-27
lines changed

2 files changed

+105
-27
lines changed

.github/workflows/build.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Build Plugin JAR File
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
release:
7+
types:
8+
- created
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
submodules: true
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v2
19+
with:
20+
distribution: 'temurin'
21+
cache: 'gradle'
22+
java-version: 17
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: 16
27+
- uses: pnpm/[email protected]
28+
name: Install pnpm
29+
id: pnpm-install
30+
with:
31+
version: 7
32+
run_install: false
33+
- name: Get pnpm store directory
34+
id: pnpm-cache
35+
run: |
36+
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
37+
- uses: actions/cache@v3
38+
name: Setup pnpm cache
39+
with:
40+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
41+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/console/pnpm-lock.yaml') }}
42+
restore-keys: |
43+
${{ runner.os }}-pnpm-store-
44+
- name: Install Frontend Dependencies
45+
run: |
46+
./gradlew pnpmInstall
47+
- name: Build with Gradle
48+
run: |
49+
# Set the version with tag name when releasing
50+
version=${{ github.event.release.tag_name }}
51+
version=${version#v}
52+
sed -i "s/version=.*-SNAPSHOT$/version=$version/1" gradle.properties
53+
./gradlew clean build -x test
54+
- name: Archive plugin-sitemap jar
55+
uses: actions/upload-artifact@v2
56+
with:
57+
name: plugin-sitemap
58+
path: |
59+
build/libs/*-plain.jar
60+
retention-days: 1
61+
62+
github-release:
63+
runs-on: ubuntu-latest
64+
needs: build
65+
if: github.event_name == 'release'
66+
steps:
67+
- name: Download plugin-sitemap jar
68+
uses: actions/download-artifact@v2
69+
with:
70+
name: plugin-sitemap
71+
path: build/libs
72+
- name: Get Name of Artifact
73+
id: get_artifact
74+
run: |
75+
ARTIFACT_PATHNAME=$(ls build/libs/*.jar | head -n 1)
76+
ARTIFACT_NAME=$(basename ${ARTIFACT_PATHNAME})
77+
echo "Artifact pathname: ${ARTIFACT_PATHNAME}"
78+
echo "Artifact name: ${ARTIFACT_NAME}"
79+
echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV
80+
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
81+
echo "RELEASE_ID=${{ github.event.release.id }}" >> $GITHUB_ENV
82+
- name: Upload a Release Asset
83+
uses: actions/github-script@v2
84+
if: github.event_name == 'release'
85+
with:
86+
github-token: ${{secrets.GITHUB_TOKEN}}
87+
script: |
88+
console.log('environment', process.versions);
89+
90+
const fs = require('fs').promises;
91+
92+
const { repo: { owner, repo }, sha } = context;
93+
console.log({ owner, repo, sha });
94+
95+
const releaseId = process.env.RELEASE_ID
96+
const artifactPathName = process.env.ARTIFACT_PATHNAME
97+
const artifactName = process.env.ARTIFACT_NAME
98+
console.log('Releasing', releaseId, artifactPathName, artifactName)
99+
100+
await github.repos.uploadReleaseAsset({
101+
owner, repo,
102+
release_id: releaseId,
103+
name: artifactName,
104+
data: await fs.readFile(artifactPathName)
105+
});

.github/workflows/workflow.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)