From 0459f89a29922bf994c171d1a01b8b91d066cecf Mon Sep 17 00:00:00 2001 From: steebchen Date: Tue, 11 Feb 2025 14:25:01 +0700 Subject: [PATCH 1/2] ci(workflows): remove preview workflow and add preview support in release Removed the `preview.yml` workflow as its functionality is now integrated into the `release.yml` workflow. Added support for creating preview releases via an input flag and adjusted related steps for tag naming and conditions in the release process. --- .github/workflows/preview.yml | 86 ----------------------------------- .github/workflows/release.yml | 29 ++++++++---- 2 files changed, 19 insertions(+), 96 deletions(-) delete mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml deleted file mode 100644 index 9719ce4e03..0000000000 --- a/.github/workflows/preview.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: preview - -on: - workflow_dispatch: - -jobs: - publish: - runs-on: ubuntu-latest-32-cores - - steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Cache Docker layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache/prebuild - key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx-${{ github.ref_name }} - ${{ runner.os }}-buildx- - - - name: Cache Docker layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache/build - key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx-${{ github.ref_name }} - ${{ runner.os }}-buildx- - - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set outputs - id: vars - run: | - set -eux - git config --global --add safe.directory "${{ github.workspace }}" - echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" - - - name: Build Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: .github/Dockerfile - load: true - tags: build-local:latest - cache-from: type=local,src=/tmp/.buildx-cache/prebuild - cache-to: type=local,dest=/tmp/.buildx-cache-new/prebuild,mode=max - platforms: linux/amd64 - - - name: Build local binaries - run: | - set -eux - docker run --rm -v "$(pwd)/artifacts/$PLATFORM:/artifacts" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts/" - env: - PLATFORM: linux/amd64 - - - name: Build and push docker image - uses: docker/build-push-action@v3 - with: - push: true - tags: ghcr.io/${{ github.repository }}:preview--${{ steps.vars.outputs.sha_short }} - cache-from: type=local,src=/tmp/.buildx-cache/build - cache-to: type=local,dest=/tmp/.buildx-cache-new/build,mode=max - platforms: linux/amd64 - build-contexts: | - artifacts=artifacts - - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache/prebuild - mv /tmp/.buildx-cache-new/prebuild /tmp/.buildx-cache/prebuild || true - rm -rf /tmp/.buildx-cache/build - mv /tmp/.buildx-cache-new/build /tmp/.buildx-cache/build || true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f5900401f9..5dbc428ed4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,6 +2,11 @@ name: release on: workflow_dispatch: + inputs: + preview: + description: 'Create a preview release' + type: boolean + default: true pull_request: types: [closed] branches: @@ -23,8 +28,12 @@ jobs: - name: Get version id: release_info run: | - cargo install cargo-get - echo "tag_name=$(cargo get workspace.package.version)" >> $GITHUB_OUTPUT + if ${{ github.event.inputs.preview }}; then + echo "tag_name=preview--$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + else + cargo install cargo-get + echo "tag_name=v$(cargo get workspace.package.version)" >> $GITHUB_OUTPUT + fi release: name: ${{ matrix.job.target }} (${{ matrix.job.os }}) @@ -109,7 +118,7 @@ jobs: - name: Archive binaries id: artifacts env: - VERSION_NAME: v${{ needs.prepare.outputs.tag_name }} + VERSION_NAME: ${{ needs.prepare.outputs.tag_name }} run: | if [ "$PLATFORM_NAME" == "linux" ]; then tar -czvf "dojo_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release katana sozo torii dojo-language-server @@ -139,14 +148,14 @@ jobs: # Upload these for use with the Docker build later - name: Upload docker binaries - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: binaries path: ${{ env.PLATFORM_NAME }} retention-days: 1 - name: Upload release artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: artifacts path: ${{ steps.artifacts.outputs.file_name }} @@ -158,10 +167,10 @@ jobs: env: GITHUB_USER: ${{ github.repository_owner }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + if: ${{ !startsWith(needs.prepare.outputs.tag_name, 'preview') }} steps: - uses: actions/checkout@v2 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: artifacts path: artifacts @@ -171,7 +180,7 @@ jobs: echo "version=$(cargo get workspace.package.version)" >> $GITHUB_OUTPUT - name: Display structure of downloaded files run: ls -R artifacts - - run: gh release create v${{ steps.version_info.outputs.version }} ./artifacts/*.gz --generate-notes --draft + - run: gh release create ${{ steps.version_info.outputs.version }} ./artifacts/*.gz --generate-notes --draft docker-build-and-push: runs-on: ubuntu-20.04-4-cores @@ -182,7 +191,7 @@ jobs: uses: actions/checkout@v2 - name: Download binaries - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: binaries path: artifacts/linux @@ -201,7 +210,7 @@ jobs: uses: docker/build-push-action@v3 with: push: true - tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:v${{ needs.prepare.outputs.tag_name }} + tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ needs.prepare.outputs.tag_name }} platforms: linux/amd64,linux/arm64 build-contexts: | artifacts=artifacts From e15a2f88de57dba21bfb341cb65c3636b9c0a06c Mon Sep 17 00:00:00 2001 From: steebchen Date: Tue, 11 Feb 2025 16:06:22 +0700 Subject: [PATCH 2/2] ci(release): parameterize artifact names with job target Updated artifact and binary names in the release workflow to include matrix job targets for improved identification and clarity in multi-target builds. --- .github/workflows/release.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5dbc428ed4..4da294bc74 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -150,14 +150,14 @@ jobs: - name: Upload docker binaries uses: actions/upload-artifact@v4 with: - name: binaries + name: binaries-${{ matrix.job.target }} path: ${{ env.PLATFORM_NAME }} retention-days: 1 - name: Upload release artifacts uses: actions/upload-artifact@v4 with: - name: artifacts + name: artifacts-${{ matrix.job.target }} path: ${{ steps.artifacts.outputs.file_name }} retention-days: 1 @@ -172,7 +172,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/download-artifact@v4 with: - name: artifacts + pattern: artifacts-* path: artifacts - id: version_info run: | @@ -193,8 +193,9 @@ jobs: - name: Download binaries uses: actions/download-artifact@v4 with: - name: binaries + pattern: binaries-* path: artifacts/linux + merge-multiple: true - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1