Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ on:
types: [published]
# Pushing a v* tag also releases: the job creates the GitHub release from the
# CHANGELOG section first. A release created with GITHUB_TOKEN doesn't fire
# `release: published`, so this never runs twice for one tag.
# `release: published`. Publishing a release on GitHub also pushes its tag;
# that push run queues behind the release run and then stops, because the
# release already exists.
push:
tags: ['v*']

Expand All @@ -22,13 +24,15 @@ jobs:
- uses: actions/checkout@v4

- name: Create GitHub release for a pushed tag
id: release
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
if gh release view "${TAG}" > /dev/null 2>&1; then
echo "Release ${TAG} already exists"
echo "Release ${TAG} already exists; its own run publishes it"
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Release notes are the CHANGELOG section for this version.
Expand All @@ -43,13 +47,15 @@ jobs:
gh release create "${TAG}" --verify-tag --title "${TAG}" --notes-file release-notes.md

- name: Build release binary
if: steps.release.outputs.skip != 'true'
run: |
swift build -c release --disable-sandbox
cp .build/release/XCForgeCLI .build/release/xcforge
file .build/release/xcforge
echo "BINARY_PATH=.build/release/xcforge" >> "$GITHUB_ENV"

- name: Package tarball (binary + xcforgeWDA)
if: steps.release.outputs.skip != 'true'
run: |
BINARY="${BINARY_PATH}"
VERSION="${GITHUB_REF_NAME}"
Expand All @@ -62,6 +68,7 @@ jobs:
echo "SHA256=$(shasum -a 256 "${TARBALL}" | awk '{print $1}')" >> "$GITHUB_ENV"

- name: Package mcpb bundle
if: steps.release.outputs.skip != 'true'
run: |
BINARY="${BINARY_PATH}"
VERSION="${GITHUB_REF_NAME}"
Expand All @@ -72,6 +79,7 @@ jobs:
echo "MCPB_SHA=${MCPB_SHA}" >> "$GITHUB_ENV"

- name: Update server.json
if: steps.release.outputs.skip != 'true'
run: |
VERSION="${GITHUB_REF_NAME}"
DOWNLOAD_URL="https://github.com/justinthevoid/xcforge/releases/download/${VERSION}/xcforge-${VERSION}.mcpb"
Expand All @@ -85,11 +93,13 @@ jobs:
server.json > server.json.tmp && mv server.json.tmp server.json

- name: Upload release assets
if: steps.release.outputs.skip != 'true'
run: gh release upload --clobber "${GITHUB_REF_NAME}" "${TARBALL}" "${MCPB}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit updated server.json
if: steps.release.outputs.skip != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
Expand All @@ -109,6 +119,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update Homebrew tap
if: steps.release.outputs.skip != 'true'
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
Expand Down
Loading