|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_version: |
| 7 | + description: "Release version, e.g. 0.11.0" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + pull_request: |
| 11 | + |
| 12 | +env: |
| 13 | + ZIG_VERSION: "0.16.0" |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-bundle: |
| 21 | + name: Build package bundle |
| 22 | + runs-on: ubuntu-24.04 |
| 23 | + outputs: |
| 24 | + bundle_filename: ${{ steps.bundle.outputs.bundle_filename }} |
| 25 | + defaults: |
| 26 | + run: |
| 27 | + shell: bash |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Install Zig |
| 34 | + uses: mlugg/setup-zig@v2 |
| 35 | + with: |
| 36 | + version: ${{ env.ZIG_VERSION }} |
| 37 | + use-cache: false |
| 38 | + |
| 39 | + - name: Install Roc |
| 40 | + uses: roc-lang/setup-roc@main |
| 41 | + with: |
| 42 | + version: nightly-new-compiler |
| 43 | + |
| 44 | + - name: Run full CI checks |
| 45 | + run: ./ci/all_tests.sh |
| 46 | + |
| 47 | + - name: Bundle package |
| 48 | + id: bundle |
| 49 | + run: | |
| 50 | + BUNDLE_OUTPUT=$(scripts/bundle.sh --output-dir dist 2>&1) |
| 51 | + echo "$BUNDLE_OUTPUT" |
| 52 | +
|
| 53 | + BUNDLE_PATH=$(echo "$BUNDLE_OUTPUT" | grep "^Created:" | awk '{print $2}') |
| 54 | + BUNDLE_FILENAME=$(basename "$BUNDLE_PATH") |
| 55 | +
|
| 56 | + if [ -z "$BUNDLE_FILENAME" ]; then |
| 57 | + echo "Error: could not extract bundle filename from roc bundle output" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | +
|
| 61 | + echo "bundle_filename=$BUNDLE_FILENAME" >> "$GITHUB_OUTPUT" |
| 62 | +
|
| 63 | + - name: Upload package bundle artifact |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: package-bundle |
| 67 | + path: dist/${{ steps.bundle.outputs.bundle_filename }} |
| 68 | + retention-days: 30 |
| 69 | + |
| 70 | + test-bundle: |
| 71 | + name: Test package bundle (${{ matrix.os }}) |
| 72 | + needs: build-bundle |
| 73 | + runs-on: ${{ matrix.os }} |
| 74 | + strategy: |
| 75 | + fail-fast: false |
| 76 | + matrix: |
| 77 | + os: |
| 78 | + - ubuntu-24.04 |
| 79 | + - macos-15-intel |
| 80 | + - windows-2025 |
| 81 | + defaults: |
| 82 | + run: |
| 83 | + shell: bash |
| 84 | + |
| 85 | + steps: |
| 86 | + - name: Checkout |
| 87 | + uses: actions/checkout@v4 |
| 88 | + |
| 89 | + - name: Install Zig |
| 90 | + uses: mlugg/setup-zig@v2 |
| 91 | + with: |
| 92 | + version: ${{ env.ZIG_VERSION }} |
| 93 | + use-cache: false |
| 94 | + |
| 95 | + - name: Install Roc |
| 96 | + uses: roc-lang/setup-roc@main |
| 97 | + with: |
| 98 | + version: nightly-new-compiler |
| 99 | + |
| 100 | + - name: Download package bundle artifact |
| 101 | + uses: actions/download-artifact@v4 |
| 102 | + with: |
| 103 | + name: package-bundle |
| 104 | + path: dist |
| 105 | + |
| 106 | + - name: Test examples against downloaded bundle |
| 107 | + run: python3 ci/test_bundle_examples.py --bundle-path "dist/${{ needs.build-bundle.outputs.bundle_filename }}" |
| 108 | + |
| 109 | + create-release: |
| 110 | + name: Create GitHub release |
| 111 | + needs: |
| 112 | + - build-bundle |
| 113 | + - test-bundle |
| 114 | + runs-on: ubuntu-24.04 |
| 115 | + if: github.event_name == 'workflow_dispatch' |
| 116 | + outputs: |
| 117 | + release_commit: ${{ steps.prepare_release.outputs.release_commit }} |
| 118 | + release_tag: ${{ steps.prepare_release.outputs.release_tag }} |
| 119 | + permissions: |
| 120 | + contents: write |
| 121 | + defaults: |
| 122 | + run: |
| 123 | + shell: bash |
| 124 | + |
| 125 | + steps: |
| 126 | + - name: Checkout |
| 127 | + uses: actions/checkout@v4 |
| 128 | + with: |
| 129 | + fetch-depth: 0 |
| 130 | + ref: ${{ github.ref_name }} |
| 131 | + |
| 132 | + - name: Download package bundle artifact |
| 133 | + uses: actions/download-artifact@v4 |
| 134 | + with: |
| 135 | + name: package-bundle |
| 136 | + path: dist |
| 137 | + |
| 138 | + - name: Install Roc |
| 139 | + uses: roc-lang/setup-roc@main |
| 140 | + with: |
| 141 | + version: nightly-new-compiler |
| 142 | + |
| 143 | + - name: Prepare release docs and examples |
| 144 | + id: prepare_release |
| 145 | + env: |
| 146 | + BUNDLE_FILENAME: ${{ needs.build-bundle.outputs.bundle_filename }} |
| 147 | + RAW_RELEASE_VERSION: ${{ github.event.inputs.release_version }} |
| 148 | + REF_TYPE: ${{ github.ref_type }} |
| 149 | + run: | |
| 150 | + if [ "$REF_TYPE" != "branch" ]; then |
| 151 | + echo "Release workflow must be run from a branch so it can commit updated example URLs." |
| 152 | + exit 1 |
| 153 | + fi |
| 154 | +
|
| 155 | + RELEASE_VERSION="${RAW_RELEASE_VERSION#v}" |
| 156 | + if [[ ! "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 157 | + echo "Release version must use x.y.z format, e.g. 0.11.0" |
| 158 | + exit 1 |
| 159 | + fi |
| 160 | +
|
| 161 | + RELEASE_TAG="$RELEASE_VERSION" |
| 162 | + BUNDLE_URL="https://github.com/lukewilliamboswell/roc-parser/releases/download/${RELEASE_TAG}/${BUNDLE_FILENAME}" |
| 163 | + set +e |
| 164 | + python3 ci/update_example_parser_url.py "$BUNDLE_URL" |
| 165 | + UPDATE_STATUS=$? |
| 166 | + set -e |
| 167 | +
|
| 168 | + if [ "$UPDATE_STATUS" -eq 2 ]; then |
| 169 | + echo "Example package URLs are already current." |
| 170 | + elif [ "$UPDATE_STATUS" -ne 0 ]; then |
| 171 | + exit "$UPDATE_STATUS" |
| 172 | + fi |
| 173 | +
|
| 174 | + DOCS_ROOT=www ./docs.sh "$RELEASE_VERSION" |
| 175 | +
|
| 176 | + git config user.name "github-actions[bot]" |
| 177 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 178 | + git add examples www |
| 179 | +
|
| 180 | + if git diff --cached --quiet; then |
| 181 | + echo "Release docs and example URLs are already current." |
| 182 | + else |
| 183 | + git commit -m "Prepare ${RELEASE_VERSION} release artifacts" |
| 184 | + git push origin HEAD:${{ github.ref_name }} |
| 185 | + fi |
| 186 | +
|
| 187 | + echo "release_commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 188 | + echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT" |
| 189 | +
|
| 190 | + - name: Create release |
| 191 | + env: |
| 192 | + GH_TOKEN: ${{ github.token }} |
| 193 | + run: | |
| 194 | + BUNDLE_FILE="dist/${{ needs.build-bundle.outputs.bundle_filename }}" |
| 195 | + ROC_VERSION=$(roc version) |
| 196 | + TARGET_COMMIT="${{ steps.prepare_release.outputs.release_commit }}" |
| 197 | + RELEASE_TAG="${{ steps.prepare_release.outputs.release_tag }}" |
| 198 | +
|
| 199 | + gh release create "$RELEASE_TAG" \ |
| 200 | + "$BUNDLE_FILE" \ |
| 201 | + --target "$TARGET_COMMIT" \ |
| 202 | + --title "$RELEASE_TAG" \ |
| 203 | + --generate-notes \ |
| 204 | + --notes "Parser package bundle built with Roc $ROC_VERSION." |
| 205 | +
|
| 206 | + deploy-docs: |
| 207 | + name: Deploy docs |
| 208 | + needs: create-release |
| 209 | + runs-on: ubuntu-latest |
| 210 | + if: github.event_name == 'workflow_dispatch' |
| 211 | + permissions: |
| 212 | + contents: read |
| 213 | + pages: write |
| 214 | + id-token: write |
| 215 | + environment: |
| 216 | + name: github-pages |
| 217 | + url: ${{ steps.deployment.outputs.page_url }} |
| 218 | + |
| 219 | + steps: |
| 220 | + - name: Checkout release commit |
| 221 | + uses: actions/checkout@v4 |
| 222 | + with: |
| 223 | + ref: ${{ needs.create-release.outputs.release_commit }} |
| 224 | + |
| 225 | + - name: Setup Pages |
| 226 | + uses: actions/configure-pages@v5 |
| 227 | + |
| 228 | + - name: Upload docs artifact |
| 229 | + uses: actions/upload-pages-artifact@v3 |
| 230 | + with: |
| 231 | + path: "./www" |
| 232 | + |
| 233 | + - name: Deploy to GitHub Pages |
| 234 | + id: deployment |
| 235 | + uses: actions/deploy-pages@v4 |
0 commit comments