Skip to content

Merge pull request #2 from Open-Tech-Foundation/release/2026-06-28 #13

Merge pull request #2 from Open-Tech-Foundation/release/2026-06-28

Merge pull request #2 from Open-Tech-Foundation/release/2026-06-28 #13

Workflow file for this run

name: Release
on:
push:
branches: [main]
permissions:
contents: write # create tags and GitHub Releases
jobs:
check-release:
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check.outputs.should_release }}
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: check
run: |
version="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')" # edit me: where the version lives
echo "version=$version" >> "$GITHUB_OUTPUT"
if [ "$version" = "0.0.0" ]; then
echo "Version is 0.0.0 (unreleased); skipping build."
echo "should_release=false" >> "$GITHUB_OUTPUT"
exit 0
fi
tag="v$version"
if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then
echo "Tag $tag already exists; skipping build."
echo "should_release=false" >> "$GITHUB_OUTPUT"
else
echo "should_release=true" >> "$GITHUB_OUTPUT"
fi
build-otf-release:
needs: [check-release]
if: needs.check-release.outputs.should_release == 'true'
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- { rust_target: "x86_64-unknown-linux-gnu", os: "ubuntu-latest", ext: "", name: "linux", arch: "x86_64" } # edit me
- { rust_target: "aarch64-unknown-linux-gnu", os: "ubuntu-latest", ext: "", name: "linux", arch: "aarch64" } # edit me
- { rust_target: "x86_64-apple-darwin", os: "macos-latest", ext: "", name: "macos", arch: "x86_64" } # edit me
- { rust_target: "aarch64-apple-darwin", os: "macos-latest", ext: "", name: "macos", arch: "aarch64" } # edit me
- { rust_target: "x86_64-pc-windows-msvc", os: "windows-latest", ext: ".exe", name: "windows", arch: "x86_64" } # edit me
# - { rust_target: "i686-unknown-linux-gnu", os: "ubuntu-latest", ext: "", name: "linux", arch: "x86" } # edit me
# - { rust_target: "aarch64-pc-windows-msvc", os: "windows-latest", ext: ".exe", name: "windows", arch: "aarch64" } # edit me
# - { rust_target: "i686-pc-windows-msvc", os: "windows-latest", ext: ".exe", name: "windows", arch: "x86" } # edit me
steps:
- uses: actions/checkout@v4
- name: Build otf-release
run: rustup target add ${{ matrix.rust_target }} && cargo build --release --target ${{ matrix.rust_target }} # edit me: cross-compile with ${{ matrix.rust_target }}
- uses: actions/upload-artifact@v4
with:
name: otf-release-${{ matrix.name }}-${{ matrix.arch }}
path: target/${{ matrix.rust_target }}/release/otf-release${{ matrix.ext }}
github-release:
needs: [check-release, build-otf-release]
if: needs.check-release.outputs.should_release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
path: .artifacts
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="v${{ needs.check-release.outputs.version }}"
if gh release view "$tag" >/dev/null 2>&1; then
echo "Release $tag already exists; nothing to do."
exit 0
fi
shopt -s globstar
mkdir -p .flat-artifacts
for file in .artifacts/**/*; do
if [ -f "$file" ]; then
dir_name=$(basename "$(dirname "$file")")
file_name=$(basename "$file")
ext="${file_name##*.}"
if [ "$ext" = "$file_name" ]; then
mv "$file" ".flat-artifacts/${dir_name}"
else
mv "$file" ".flat-artifacts/${dir_name}.${ext}"
fi
fi
done
gh release create "$tag" --target main --title "$tag" --generate-notes .flat-artifacts/*