From 8f3f6be3b304bb040c304bdcc17ca20d5774667e Mon Sep 17 00:00:00 2001 From: Satya Date: Wed, 24 Apr 2024 13:12:33 +0800 Subject: [PATCH] chore: Add github action file to include Earthly --- .github/workflows/build-release.yml | 75 +++++++++++++++++++++++++++++ Earthfile | 12 +++-- 2 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build-release.yml diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..a35b49a --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,75 @@ +name: Build and Release +on: + push: + tags: + - 'v*' + +jobs: + buildAndPush: + runs-on: ubuntu-latest + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + FORCE_COLOR: 1 + steps: + - uses: earthly/actions-setup@v1 + with: + version: v0.8.0 + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + with: + image: tonistiigi/binfmt:latest + platforms: all + - uses: actions/checkout@v4 + - name: Docker Login + run: docker login --username "$DOCKERHUB_USERNAME" --password "$DOCKERHUB_TOKEN" + - name: Run build + run: earthly --ci --push +build-all-platforms + + +# - uses: actions/checkout@v2 +# - name: Set up JDK 21 +# uses: actions/setup-java@v2 +# with: +# java-version: 21 +# distribution: 'liberica' +# - name: Decode GPG Key +# run: | +# mkdir -p ~/.gradle/ +# echo "${{secrets.SIGNING_KEY}}" > ~/.gradle/secring.gpg.b64 +# base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg +# - name: Grant execute permission for gradlew +# run: chmod +x gradlew +# - name: Build with Gradle +# run: ./gradlew clean build -Psigning.keyId=${{ secrets.SIGNING_KEY_ID }} -Psigning.password=${{ secrets.SIGNING_PASSWORD }} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg) --warn --stacktrace +# - name: 'Get Version Number' +# run: | +# ARTIFACT_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}') +# echo "VERSION=${ARTIFACT_VERSION}" >> $GITHUB_ENV +# - name: Release +# uses: softprops/action-gh-release@v1 +# if: startsWith(github.ref, 'refs/tags/') +# with: +# files: | +# build/libs/yaci*-${{env.VERSION}}.jar +# prerelease: true +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# - name: Set up QEMU +# uses: docker/setup-qemu-action@v2 +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v2 +# - name: Login to Docker Hub +# uses: docker/login-action@v2 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} +# - name: Build and push +# uses: docker/build-push-action@v4 +# with: +# context: . +# platforms: linux/amd64,linux/arm64 +# push: true +# build-args: APP_VERSION=${{env.VERSION}} +# tags: bloxbean/yaci-cli:latest,bloxbean/yaci-cli:${{ env.VERSION }} diff --git a/Earthfile b/Earthfile index 8dd3a3e..822e183 100644 --- a/Earthfile +++ b/Earthfile @@ -2,19 +2,25 @@ VERSION 0.8 ARG --global ALL_BUILD_TARGETS="cli viewer" ARG --global DOCKER_IMAGE_PREFIX="yaci" -ARG --global TAG="0.0.20-beta2-SNAPSHOT" +ARG --global TAG="0.0.1-preview" -all: +build: LOCALLY FOR image_target IN $ALL_BUILD_TARGETS BUILD +$image_target END +build-all-platforms: + LOCALLY + FOR image_target IN $ALL_BUILD_TARGETS + BUILD --platform=linux/amd64 --platform=linux/arm64 +$image_target + END + cli: ARG EARTHLY_TARGET_NAME ARG EARTHLY_GIT_SHORT_HASH FROM DOCKERFILE --build-arg APP_VERSION=${TAG} --build-arg COMMIT_ID=${EARTHLY_GIT_SHORT_HASH} applications/${EARTHLY_TARGET_NAME}/. - SAVE IMAGE bloxbean/${DOCKER_IMAGE_PREFIX}-${EARTHLY_TARGET_NAME}:${TAG} + SAVE IMAGE bloxbean/${DOCKER_IMAGE_PREFIX}-devkit:${TAG} viewer: ARG EARTHLY_TARGET_NAME