|
| 1 | +name: GitHub Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + branch: |
| 10 | + description: 'Branch to release from' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + version: |
| 14 | + description: 'Version number (e.g., 0.1.0)' |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + |
| 18 | +jobs: |
| 19 | + release: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + permissions: |
| 22 | + contents: write |
| 23 | + steps: |
| 24 | + # --- Determine tag and checkout --- |
| 25 | + |
| 26 | + - name: Determine tag (tag push) |
| 27 | + if: github.event_name == 'push' |
| 28 | + run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV |
| 29 | + |
| 30 | + - name: Determine tag (workflow_dispatch) |
| 31 | + if: github.event_name == 'workflow_dispatch' |
| 32 | + run: | |
| 33 | + BRANCH="${{ github.event.inputs.branch }}" |
| 34 | + VERSION="${{ github.event.inputs.version }}" |
| 35 | + DEFAULT_BRANCH="${{ github.event.repository.default_branch }}" |
| 36 | + if [ "$BRANCH" = "$DEFAULT_BRANCH" ]; then |
| 37 | + echo "TAG_NAME=v${VERSION}" >> $GITHUB_ENV |
| 38 | + else |
| 39 | + echo "TAG_NAME=v${BRANCH}-${VERSION}" >> $GITHUB_ENV |
| 40 | + fi |
| 41 | + echo "RELEASE_BRANCH=${BRANCH}" >> $GITHUB_ENV |
| 42 | +
|
| 43 | + - uses: actions/checkout@v4 |
| 44 | + if: github.event_name == 'push' |
| 45 | + with: |
| 46 | + ref: ${{ env.TAG_NAME }} |
| 47 | + |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + if: github.event_name == 'workflow_dispatch' |
| 50 | + with: |
| 51 | + ref: ${{ github.event.inputs.branch }} |
| 52 | + fetch-depth: 0 |
| 53 | + |
| 54 | + - name: Create and push tag (workflow_dispatch) |
| 55 | + if: github.event_name == 'workflow_dispatch' |
| 56 | + run: | |
| 57 | + git config --local user.email "action@github.com" |
| 58 | + git config --local user.name "GitHub Action" |
| 59 | + git tag "${{ env.TAG_NAME }}" |
| 60 | + git push origin "${{ env.TAG_NAME }}" |
| 61 | +
|
| 62 | + # --- Determine prerelease status --- |
| 63 | + |
| 64 | + - name: Check if prerelease |
| 65 | + run: | |
| 66 | + TAG="${{ env.TAG_NAME }}" |
| 67 | + TAG_BODY="${TAG#v}" |
| 68 | + if echo "$TAG_BODY" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then |
| 69 | + echo "IS_PRERELEASE=false" >> $GITHUB_ENV |
| 70 | + else |
| 71 | + echo "IS_PRERELEASE=true" >> $GITHUB_ENV |
| 72 | + fi |
| 73 | +
|
| 74 | + # --- Setup build tools --- |
| 75 | + |
| 76 | + - name: Setup Node.js |
| 77 | + uses: actions/setup-node@v4 |
| 78 | + with: |
| 79 | + node-version: '20' |
| 80 | + |
| 81 | + - name: Install mise |
| 82 | + uses: jdx/mise-action@v2 |
| 83 | + with: |
| 84 | + experimental: true |
| 85 | + |
| 86 | + - name: Install Bun |
| 87 | + uses: oven-sh/setup-bun@v2 |
| 88 | + |
| 89 | + - name: Cache Bun |
| 90 | + uses: actions/cache@v4 |
| 91 | + with: |
| 92 | + path: ~/.bun/install/cache |
| 93 | + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }} |
| 94 | + restore-keys: | |
| 95 | + ${{ runner.os }}-bun- |
| 96 | +
|
| 97 | + - name: Cache Elm |
| 98 | + uses: actions/cache@v4 |
| 99 | + with: |
| 100 | + path: ~/.elm |
| 101 | + key: ${{ runner.os }}-elm-${{ hashFiles('**/elm.json') }} |
| 102 | + restore-keys: | |
| 103 | + ${{ runner.os }}-elm- |
| 104 | +
|
| 105 | + - name: Install dependencies |
| 106 | + run: bun install |
| 107 | + |
| 108 | + - name: Setup Elm tooling |
| 109 | + run: mise run setup:elm-tooling |
| 110 | + |
| 111 | + # --- Build CLI binaries --- |
| 112 | + |
| 113 | + - name: Build CLI binaries (all platforms) |
| 114 | + run: mise run build:cli-binaries |
| 115 | + |
| 116 | + # --- Build WASM interpreter (if available) --- |
| 117 | + |
| 118 | + - name: Check if interpreter-wasm build exists |
| 119 | + id: check-wasm |
| 120 | + run: | |
| 121 | + if mise tasks 2>/dev/null | grep -q 'build:interpreter-wasm'; then |
| 122 | + echo "available=true" >> $GITHUB_OUTPUT |
| 123 | + else |
| 124 | + echo "available=false" >> $GITHUB_OUTPUT |
| 125 | + fi |
| 126 | +
|
| 127 | + - name: Build interpreter WASM component |
| 128 | + if: steps.check-wasm.outputs.available == 'true' |
| 129 | + run: mise run build:interpreter-wasm |
| 130 | + |
| 131 | + # --- Package artifacts --- |
| 132 | + |
| 133 | + - name: Package CLI binaries |
| 134 | + run: | |
| 135 | + cp dist/binaries/morphir-linux-amd64 . |
| 136 | + cp dist/binaries/morphir-linux-arm64 . |
| 137 | + cp dist/binaries/morphir-darwin-arm64 . |
| 138 | + cp dist/binaries/morphir-windows-amd64.exe . |
| 139 | +
|
| 140 | + - name: Package WASM artifacts |
| 141 | + if: steps.check-wasm.outputs.available == 'true' |
| 142 | + run: | |
| 143 | + PKG=packages/morphir-interpreter-wasm |
| 144 | +
|
| 145 | + cp "$PKG/build/interpreter.wasm" interpreter.wasm |
| 146 | +
|
| 147 | + # WIT-only tarball |
| 148 | + tar -czf morphir-interpreter-wit.tar.gz -C "$PKG" wit/ |
| 149 | +
|
| 150 | + # WASM + WIT combined tarball |
| 151 | + mkdir -p _release/morphir-interpreter |
| 152 | + cp "$PKG/build/interpreter.wasm" _release/morphir-interpreter/ |
| 153 | + cp -r "$PKG/wit" _release/morphir-interpreter/ |
| 154 | + tar -czf morphir-interpreter-wasm.tar.gz -C _release morphir-interpreter/ |
| 155 | + rm -rf _release |
| 156 | +
|
| 157 | + # --- Collect release files --- |
| 158 | + |
| 159 | + - name: Collect release file list |
| 160 | + id: release-files |
| 161 | + run: | |
| 162 | + FILES="morphir-linux-amd64 |
| 163 | + morphir-linux-arm64 |
| 164 | + morphir-darwin-arm64 |
| 165 | + morphir-windows-amd64.exe |
| 166 | + scripts/install.sh |
| 167 | + scripts/install.ps1 |
| 168 | + scripts/morphir |
| 169 | + scripts/morphir.bat" |
| 170 | +
|
| 171 | + if [ -f interpreter.wasm ]; then |
| 172 | + FILES="$FILES |
| 173 | + interpreter.wasm |
| 174 | + morphir-interpreter-wit.tar.gz |
| 175 | + morphir-interpreter-wasm.tar.gz" |
| 176 | + fi |
| 177 | +
|
| 178 | + # Write to file for the release step |
| 179 | + echo "$FILES" > release-files.txt |
| 180 | + cat release-files.txt |
| 181 | +
|
| 182 | + # --- Release --- |
| 183 | + |
| 184 | + - name: Create GitHub Release |
| 185 | + uses: softprops/action-gh-release@v2 |
| 186 | + with: |
| 187 | + tag_name: ${{ env.TAG_NAME }} |
| 188 | + name: ${{ env.TAG_NAME }} |
| 189 | + files: | |
| 190 | + morphir-linux-amd64 |
| 191 | + morphir-linux-arm64 |
| 192 | + morphir-darwin-arm64 |
| 193 | + morphir-windows-amd64.exe |
| 194 | + scripts/install.sh |
| 195 | + scripts/install.ps1 |
| 196 | + scripts/morphir |
| 197 | + scripts/morphir.bat |
| 198 | + interpreter.wasm |
| 199 | + morphir-interpreter-wit.tar.gz |
| 200 | + morphir-interpreter-wasm.tar.gz |
| 201 | + fail_on_unmatched_files: false |
| 202 | + generate_release_notes: true |
| 203 | + draft: false |
| 204 | + prerelease: ${{ env.IS_PRERELEASE == 'true' }} |
| 205 | + env: |
| 206 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments