From 8d5b09bd02809578ee5fb1d519d4b1972e6eb126 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 5 Jun 2024 15:18:27 +0200 Subject: [PATCH] ci: Setup workflows for proper release --- .github/workflows/build_pull_request.yml | 25 ++++++++++ ...pull_request.yml => open_pull_request.yml} | 0 .github/workflows/release.yml | 46 ++++++++----------- build.gradle.kts | 2 +- 4 files changed, 46 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/build_pull_request.yml rename .github/workflows/{pull_request.yml => open_pull_request.yml} (100%) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml new file mode 100644 index 0000000..250871b --- /dev/null +++ b/.github/workflows/build_pull_request.yml @@ -0,0 +1,25 @@ +name: Build pull request + +on: + workflow_dispatch: + pull_request: + branches: + - dev + +jobs: + release: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Cache Gradle + uses: burrunan/gradle-cache-action@v1 + + - name: Build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./gradlew build --no-daemon diff --git a/.github/workflows/pull_request.yml b/.github/workflows/open_pull_request.yml similarity index 100% rename from .github/workflows/pull_request.yml rename to .github/workflows/open_pull_request.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8043363..b007442 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,10 +6,6 @@ on: branches: - main - dev - pull_request: - branches: - - main - - dev jobs: release: @@ -44,6 +40,13 @@ jobs: - name: Install dependencies run: npm install + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + fingerprint: ${{ env.GPG_FINGERPRINT }} + - name: Release env: GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }} @@ -51,39 +54,30 @@ jobs: - name: Setup QEMU uses: docker/setup-qemu-action@v3 - with: - image: tonistiigi/binfmt:latest - platforms: all - - name: Setup Docker buildx - uses: docker/setup-buildx-action@v3 + - name: Extract metadata for the Docker image + id: metadata + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ env.IMAGE_NAME }} + flavor: | + latest=${{ startsWith(github.ref, 'refs/heads/main') }} + suffix=-${{ github.sha }} - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GH_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: metadata - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - flavor: | - latest=${{ startsWith(github.ref, 'refs/heads/main') }} - suffix=-${{ github.sha }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image id: build uses: docker/build-push-action@v5 with: - build-args: GH_TOKEN=${{ secrets.GH_TOKEN }} - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64/v8 - cache-to: type=gha,mode=max,ignore-error=true + platforms: linux/amd64,linux/arm64 cache-from: type=gha + cache-to: type=gha,mode=max,ignore-error=true push: true tags: ${{ steps.metadata.outputs.tags }} labels: ${{ steps.metadata.outputs.labels }} diff --git a/build.gradle.kts b/build.gradle.kts index a62319d..bc19853 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ tasks { // Tracking: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435 register("publish") { group = "publishing" - dependsOn(shadowJar) + dependsOn(startShadowScripts) } }