From 1ab80ad432534c2902d04e7151a00f6113678619 Mon Sep 17 00:00:00 2001 From: yinheli Date: Thu, 7 Dec 2023 20:46:04 +0800 Subject: [PATCH] chore: add github actions --- .github/workflows/build.yaml | 42 ++++++++++++++++++++++++ .github/workflows/release.yaml | 59 ++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..96d2d6b --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,42 @@ +name: build + +on: + push: + branches: + - master + - develop + - xpc/* + pull_request: + branches: + - master + - develop + - xpc/* + + workflow_dispatch: + +permissions: + contents: write + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + with: + gradle-version: 7.6 + + - name: Build with Gradle + run: gradle pz diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..7f23b63 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,59 @@ +name: Create release and upload binaries + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]*" + + workflow_dispatch: + +permissions: + contents: write + +jobs: + release: + name: Build release binaries + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Update version + run: | + tag=${GITHUB_REF#refs/tags/} + regex="v([0-9]+\.[0-9]+\.[0-9]+).*" + if [[ $tag =~ $regex ]]; then + extracted_version="${BASH_REMATCH[1]}" + echo "Extracted version: $extracted_version" + else + echo "Extracted version failed" + exit 1 + fi + + sed -i "s/^version=.*/version=${tag}/" src/main/resources/plugin-descriptor.properties + sed -i "s/elasticsearch.version=.*/elasticsearch.version=${extracted_version}/" src/main/resources/plugin-descriptor.properties + sed -i "s/^version.*/version='${tag}'/" build.gradle + sed -i "s/org.elasticsearch:elasticsearch:.*/org.elasticsearch:elasticsearch:${extracted_version}'/" build.gradle + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + with: + gradle-version: 7.6 + + - name: Build with Gradle + run: gradle pz + + - name: Add Artifacts to Release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: build/distributions/*.zip