|
| 1 | +name: Release Loom |
| 2 | + |
| 3 | +# Loom is EXPERIMENTAL: GitHub-release-only (no crates.io publish) while the |
| 4 | +# `loom-0.x` series lasts — see experimento/README.md and plan.md §6. |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - 'loom-*' |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + tag: |
| 13 | + description: 'Release tag (e.g., loom-0.1.0)' |
| 14 | + required: true |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + |
| 19 | +env: |
| 20 | + CARGO_TERM_COLOR: always |
| 21 | + |
| 22 | +jobs: |
| 23 | + resolve-version: |
| 24 | + name: Resolve version |
| 25 | + runs-on: ubuntu-latest |
| 26 | + outputs: |
| 27 | + tag: ${{ steps.resolve.outputs.tag }} |
| 28 | + version: ${{ steps.resolve.outputs.version }} |
| 29 | + steps: |
| 30 | + - name: Resolve tag and version |
| 31 | + id: resolve |
| 32 | + shell: bash |
| 33 | + run: | |
| 34 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 35 | + TAG="${{ github.event.inputs.tag }}" |
| 36 | + else |
| 37 | + TAG="${{ github.ref_name }}" |
| 38 | + fi |
| 39 | +
|
| 40 | + if [[ "$TAG" != loom-* ]]; then |
| 41 | + echo "ERROR: tag '$TAG' is not a Loom release (must start with loom-)" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | +
|
| 45 | + VERSION="${TAG#loom-}" |
| 46 | + echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
| 47 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 48 | + echo "Building Loom $VERSION from tag $TAG" |
| 49 | +
|
| 50 | + build-loom: |
| 51 | + name: Build Loom (${{ matrix.target }}) |
| 52 | + needs: [resolve-version] |
| 53 | + runs-on: ${{ matrix.os }} |
| 54 | + strategy: |
| 55 | + matrix: |
| 56 | + include: |
| 57 | + - target: x86_64-unknown-linux-gnu |
| 58 | + os: ubuntu-latest |
| 59 | + archive: tar.gz |
| 60 | + - target: x86_64-apple-darwin |
| 61 | + os: macos-latest |
| 62 | + archive: tar.gz |
| 63 | + - target: aarch64-apple-darwin |
| 64 | + os: macos-latest |
| 65 | + archive: tar.gz |
| 66 | + - target: x86_64-pc-windows-msvc |
| 67 | + os: windows-latest |
| 68 | + archive: zip |
| 69 | + |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v6 |
| 72 | + with: |
| 73 | + ref: ${{ needs.resolve-version.outputs.tag }} |
| 74 | + |
| 75 | + - name: Install Rust toolchain |
| 76 | + uses: dtolnay/rust-toolchain@stable |
| 77 | + with: |
| 78 | + targets: ${{ matrix.target }} |
| 79 | + |
| 80 | + - name: Install Node |
| 81 | + uses: actions/setup-node@v4 |
| 82 | + with: |
| 83 | + node-version: 22 |
| 84 | + cache: npm |
| 85 | + cache-dependency-path: experimento/web/package-lock.json |
| 86 | + |
| 87 | + - name: Verify Cargo.toml version matches tag |
| 88 | + shell: bash |
| 89 | + run: | |
| 90 | + CARGO_VERSION=$(grep '^version' experimento/Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') |
| 91 | + TAG_VERSION="${{ needs.resolve-version.outputs.version }}" |
| 92 | + if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then |
| 93 | + echo "ERROR: experimento/Cargo.toml version ($CARGO_VERSION) does not match tag version ($TAG_VERSION)" |
| 94 | + exit 1 |
| 95 | + fi |
| 96 | +
|
| 97 | + - name: Build frontend (embedded via rust-embed) |
| 98 | + shell: bash |
| 99 | + working-directory: experimento/web |
| 100 | + run: | |
| 101 | + npm ci |
| 102 | + npm run build |
| 103 | + test -f dist/index.html |
| 104 | +
|
| 105 | + - name: Build release binary |
| 106 | + run: cargo build --release --manifest-path experimento/Cargo.toml --target ${{ matrix.target }} |
| 107 | + |
| 108 | + - name: Package (Unix) |
| 109 | + if: matrix.archive == 'tar.gz' |
| 110 | + shell: bash |
| 111 | + run: | |
| 112 | + BINARY=target/${{ matrix.target }}/release/straymark-loom |
| 113 | + ARCHIVE=straymark-loom-v${{ needs.resolve-version.outputs.version }}-${{ matrix.target }}.tar.gz |
| 114 | + tar czf "$ARCHIVE" -C "$(dirname "$BINARY")" "$(basename "$BINARY")" |
| 115 | + echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV" |
| 116 | +
|
| 117 | + - name: Package (Windows) |
| 118 | + if: matrix.archive == 'zip' |
| 119 | + shell: bash |
| 120 | + run: | |
| 121 | + BINARY=target/${{ matrix.target }}/release/straymark-loom.exe |
| 122 | + ARCHIVE=straymark-loom-v${{ needs.resolve-version.outputs.version }}-${{ matrix.target }}.zip |
| 123 | + cp "$BINARY" straymark-loom.exe |
| 124 | + 7z a "$ARCHIVE" straymark-loom.exe |
| 125 | + echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV" |
| 126 | +
|
| 127 | + - name: Upload binary artifact |
| 128 | + uses: actions/upload-artifact@v7 |
| 129 | + with: |
| 130 | + name: loom-${{ matrix.target }} |
| 131 | + path: ${{ env.ARCHIVE }} |
| 132 | + |
| 133 | + upload-to-release: |
| 134 | + name: Upload binaries to release |
| 135 | + needs: [resolve-version, build-loom] |
| 136 | + runs-on: ubuntu-latest |
| 137 | + steps: |
| 138 | + - uses: actions/checkout@v6 |
| 139 | + |
| 140 | + - name: Download all artifacts |
| 141 | + uses: actions/download-artifact@v8 |
| 142 | + with: |
| 143 | + path: release-artifacts |
| 144 | + |
| 145 | + - name: Collect release files |
| 146 | + run: | |
| 147 | + mkdir -p release |
| 148 | + find release-artifacts -type f \( -name "*.zip" -o -name "*.tar.gz" \) -exec cp {} release/ \; |
| 149 | + ls -la release/ |
| 150 | +
|
| 151 | + - name: Create or update GitHub Release |
| 152 | + env: |
| 153 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 154 | + shell: bash |
| 155 | + run: | |
| 156 | + TAG="${{ needs.resolve-version.outputs.tag }}" |
| 157 | + VERSION="${{ needs.resolve-version.outputs.version }}" |
| 158 | +
|
| 159 | + if gh release view "$TAG" > /dev/null 2>&1; then |
| 160 | + echo "Release $TAG exists, uploading binaries..." |
| 161 | + gh release upload "$TAG" release/* --clobber |
| 162 | + else |
| 163 | + echo "Creating release $TAG..." |
| 164 | + # NOT --latest: Loom is experimental; the CLI release stays the |
| 165 | + # repo's "latest" so update flows are unaffected. |
| 166 | + gh release create "$TAG" \ |
| 167 | + --title "StrayMark Loom $VERSION (EXPERIMENTAL)" \ |
| 168 | + --generate-notes \ |
| 169 | + --latest=false \ |
| 170 | + release/* |
| 171 | + fi |
| 172 | +
|
| 173 | + - name: Delete previous Loom releases |
| 174 | + env: |
| 175 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 176 | + shell: bash |
| 177 | + run: | |
| 178 | + CURRENT_TAG="${{ needs.resolve-version.outputs.tag }}" |
| 179 | + gh release list --json tagName --jq '.[].tagName' | while read -r tag; do |
| 180 | + if [[ "$tag" == loom-* && "$tag" != "$CURRENT_TAG" ]]; then |
| 181 | + echo "Deleting old release $tag..." |
| 182 | + gh release delete "$tag" --yes --cleanup-tag |
| 183 | + fi |
| 184 | + done |
0 commit comments