From b6d4e3371bb16adff69a1aae31072aec3bbd5f4f Mon Sep 17 00:00:00 2001 From: lokka30 Date: Sat, 23 Nov 2024 10:56:51 +0800 Subject: [PATCH] project: add workflows; version now 1.0.1 --- .github/workflows/mvn-build.yml | 34 +++++++++++++++ .github/workflows/mvn-deploy.yml | 72 ++++++++++++++++++++++++++++++++ pom.xml | 2 +- 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/mvn-build.yml create mode 100644 .github/workflows/mvn-deploy.yml diff --git a/.github/workflows/mvn-build.yml b/.github/workflows/mvn-build.yml new file mode 100644 index 0000000..68a3a2f --- /dev/null +++ b/.github/workflows/mvn-build.yml @@ -0,0 +1,34 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + pull_request: + +jobs: + build: + + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: maven + + - name: Build with Maven + run: mvn --batch-mode clean diff --git a/.github/workflows/mvn-deploy.yml b/.github/workflows/mvn-deploy.yml new file mode 100644 index 0000000..028442d --- /dev/null +++ b/.github/workflows/mvn-deploy.yml @@ -0,0 +1,72 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +on: + release: + types: [ published ] + +jobs: + build-publish: + + runs-on: ubuntu-latest + + permissions: + contents: write + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: maven + + - name: Build and deploy with Maven + run: mvn --batch-mode deploy --settings settings.xml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: AButler/upload-release-assets@v3.0 + with: + files: "lachsbot/target/lachsbot.jar" + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to GitHub CR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and Push + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/pom.xml b/pom.xml index 5e89556..fbb9caf 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ lachsbot space.lachy.lachsbot - 1.0-SNAPSHOT + 1.0.1-SNAPSHOT jar lachsbot