name: Create Release on: workflow_call: inputs: tag: description: 'Full commit SHA for tagging' required: true type: string branch: description: 'Branch name used as release tag suffix (e.g. canary_experimental)' required: false type: string default: 'canary_experimental' jobs: release: runs-on: ubuntu-latest permissions: contents: write steps: # Checkout for git log access — no submodules needed - name: Checkout repository uses: actions/checkout@v6 with: fetch-depth: 0 - name: Build release notes id: meta env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} run: | FULL_SHA="${{ inputs.tag }}" SHORT_SHA="${FULL_SHA::7}" BRANCH="${{ inputs.branch }}" TAG_NAME="${SHORT_SHA}_${BRANCH}" echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT" PREV_TAG=$(gh release list \ --repo "${REPO}" \ --limit 1 \ --json tagName \ --jq '.[0].tagName' 2>/dev/null || echo "") if [ -n "${PREV_TAG}" ]; then PREV_SHA=$(git rev-parse "${PREV_TAG}^{}" 2>/dev/null || \ git rev-parse "${PREV_TAG}" 2>/dev/null || echo "") fi if [ -n "${PREV_SHA}" ]; then COMMITS=$(git log --format="- %s (\`%h\`)" --abbrev=7 "${PREV_SHA}..${FULL_SHA}" --) COMPARE_URL="https://github.com/${REPO}/compare/${PREV_TAG}...${TAG_NAME}" else COMMITS=$(git log --format="- %s (\`%h\`)" --abbrev=7 -1 "${FULL_SHA}" --) COMPARE_URL="" fi # Assemble body { echo "body<> "$GITHUB_OUTPUT" # --- Download artifacts only for platforms that succeeded --- - name: Download Windows artifacts uses: actions/download-artifact@v8 with: name: xenia_canary_windows path: artifacts/windows/xenia_canary - name: Download Linux artifacts uses: actions/download-artifact@v8 with: name: xenia_canary_linux.tar.xz path: artifacts # Uncomment when platforms are enabled: # - name: Download macOS artifacts # uses: actions/download-artifact@v8 # with: # name: xenia_canary_macos # path: artifacts/macos # - name: Download Android artifacts # uses: actions/download-artifact@v8 # with: # name: xenia_canary_android # path: artifacts/android # --- Package everything into release assets --- - name: Package release assets run: | mkdir -p release_assets # Windows if [ -d "artifacts/windows/xenia_canary" ]; then cd artifacts/windows/xenia_canary zip -r ../../../release_assets/xenia_canary_windows.zip . -x "*.pdb" cd ../../.. fi # Linux (already tar.gz) if [ -f "artifacts/xenia_canary_linux.tar.xz" ]; then cp artifacts/xenia_canary_linux.tar.xz release_assets/ fi # macOS (uncomment when enabled) # if [ -f "artifacts/macos/xenia_canary_macos.tar.gz" ]; then # cp artifacts/macos/xenia_canary_macos.tar.gz release_assets/ # fi # Android (uncomment when enabled) # if [ -f "artifacts/android/xenia_canary_android.zip" ]; then # cp artifacts/android/xenia_canary_android.zip release_assets/ # fi echo "=== Release assets ===" ls -lh release_assets/ # --- Create the release --- - name: Create GitHub Release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} TAG: ${{ steps.meta.outputs.tag_name }} BODY: ${{ steps.meta.outputs.body }} TARGET: ${{ inputs.tag }} run: | echo "${BODY}" > release_notes.md echo "Creating release: ${TAG}" # Check if tag/release already exists (re-run safety) if gh release view "${TAG}" --repo "${REPO}" --json tagName 2>/dev/null; then echo "Release ${TAG} exists, uploading new assets..." gh release upload "${TAG}" \ --repo "${REPO}" \ --clobber \ release_assets/* else gh release create "${TAG}" \ --repo "${REPO}" \ --target "${{ inputs.tag }}" \ --title "${TAG}" \ --notes-file release_notes.md \ --notes "${BODY}" \ --latest \ release_assets/* fi echo "✅ Release ${TAG} published"