Skip to content

Commit

Permalink
ci(release): add support for preview releases
Browse files Browse the repository at this point in the history
Added inputs to trigger preview releases in the workflow.
Adjusted tag generation, release creation, and Docker tags
handling to accommodate preview releases.
  • Loading branch information
steebchen committed Feb 13, 2025
1 parent ac52ea6 commit fc17c42
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 || 'false' }}" == "true" ]]; 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 }})
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -158,7 +167,7 @@ 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@v4
Expand All @@ -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
Expand All @@ -186,6 +195,7 @@ jobs:
with:
pattern: binaries-*
path: artifacts/linux
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand All @@ -201,7 +211,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

0 comments on commit fc17c42

Please sign in to comment.