diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index da5ce26..e52acd6 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -1,8 +1,13 @@ -name: Trunk build +name: Trunk / release build on: push: branch: develop + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+-[0-9]+' + - '[0-9]+.[0-9]+.[0-9]+-[0-9]+' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -24,6 +29,19 @@ jobs: with: fetch-depth: 0 + - name: Check if commit needs a release upload + run: | + if [ "${{ github.ref_type }}" = "tag" ]; then + echo "PRERELEASE=''" >> "$GITHUB_ENV" + echo "RELEASE_NAME='${{ github.ref_name }}'" >> "$GITHUB_ENV" + elif "${{ github.ref }}" = "refs/heads/develop" ]; then + echo "PRERELEASE=--prerelease" >> "$GITHUB_ENV" + echo "RELEASENAME=trunk" >> "$GITHUB_ENV" + else + echo "Not a tag or develop branch, skipping upload" + echo "SKIP_UPLOAD=1" >> "$GITHUB_ENV" + fi + - name: Build yggstack executables run: | set -e @@ -210,15 +228,18 @@ jobs: #echo "::endgroup::" - name: Publish release + if: ${{ env.SKIP_UPLOAD != '1' }} run: | - gh release create trunk --prerelease yggstack-* || gh release upload trunk yggstack-* --clobber + gh release create "${{ env.RELEASENAME }}" "${{ env.PRERELEASE }}" yggstack-* || gh release upload "${{ env.RELEASENAME }}" yggstack-* --clobber env: GH_TOKEN: ${{ github.token }} - name: Set up Docker Buildx + if: ${{ env.SKIP_UPLOAD != '1' }} uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry + if: ${{ env.SKIP_UPLOAD != '1' }} uses: docker/login-action@v3 with: registry: ghcr.io @@ -226,10 +247,11 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push yggstack container image + if: ${{ env.SKIP_UPLOAD != '1' }} uses: docker/build-push-action@v6 with: context: . file: Dockerfile.static platforms: linux/386, linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64, linux/ppc64le, linux/riscv64, linux/s390x push: true - tags: ghcr.io/yggdrasil-network/yggstack:trunk + tags: ghcr.io/yggdrasil-network/yggstack:${{ env.RELEASENAME }}