Release #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Release version without the leading v | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| prepare-release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.release_meta.outputs.version }} | |
| tag: ${{ steps.release_meta.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.x" | |
| - name: Normalize version | |
| id: release_meta | |
| shell: bash | |
| env: | |
| INPUT_VERSION: ${{ github.event.inputs.version }} | |
| run: bash ./scripts/github-actions/normalize_version.sh | |
| - name: Update workspace version | |
| env: | |
| VERSION: ${{ steps.release_meta.outputs.version }} | |
| run: python3 ./scripts/github-actions/update_workspace_version.py | |
| - name: Refresh lockfile | |
| run: cargo check -p vs --all-features | |
| - name: Commit release version | |
| shell: bash | |
| env: | |
| VERSION: ${{ steps.release_meta.outputs.version }} | |
| run: bash ./scripts/github-actions/commit_release.sh | |
| - name: Push commit and tag | |
| shell: bash | |
| env: | |
| TAG: ${{ steps.release_meta.outputs.tag }} | |
| run: bash ./scripts/github-actions/push_commit_and_tag.sh | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.release_meta.outputs.tag }} | |
| name: ${{ steps.release_meta.outputs.tag }} | |
| generate_release_notes: true | |
| build-targets: | |
| needs: prepare-release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.matrix.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ needs.prepare-release.outputs.tag }} | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Generate build target matrix | |
| id: matrix | |
| run: python3 ./scripts/github-actions/generate_build_matrix.py | |
| build-release-artifacts: | |
| name: Release ${{ matrix.feature.label }} on ${{ matrix.target.target }} | |
| needs: [prepare-release, build-targets] | |
| runs-on: ${{ matrix.target.runner }} | |
| env: | |
| BUILD_PROFILE: min-size | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: ${{ fromJson(needs.build-targets.outputs.matrix).include }} | |
| feature: | |
| - label: lua | |
| flags: lua | |
| - label: wasi | |
| flags: wasi | |
| - label: full | |
| flags: full | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ needs.prepare-release.outputs.tag }} | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Install cross | |
| if: ${{ matrix.target.builder == 'cross' }} | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cross | |
| - name: Add Rust target | |
| run: rustup target add ${{ matrix.target.target }} | |
| - name: Build minimal binary | |
| shell: bash | |
| env: | |
| BUILD_TARGET: ${{ matrix.target.target }} | |
| BUILD_TOOL: ${{ matrix.target.builder }} | |
| FEATURE_FLAGS: ${{ matrix.feature.flags }} | |
| run: bash ./scripts/github-actions/build_binary.sh | |
| - name: Package Unix release asset | |
| if: ${{ runner.os != 'Windows' }} | |
| shell: bash | |
| env: | |
| BUILD_TARGET: ${{ matrix.target.target }} | |
| VERSION: ${{ needs.prepare-release.outputs.version }} | |
| TARGET_TRIPLE: ${{ matrix.target.target }} | |
| ARTIFACT_VARIANT: ${{ matrix.feature.label }} | |
| run: bash ./scripts/github-actions/package_unix.sh | |
| - name: Package Windows release asset | |
| if: ${{ runner.os == 'Windows' }} | |
| shell: pwsh | |
| env: | |
| BUILD_TARGET: ${{ matrix.target.target }} | |
| VERSION: ${{ needs.prepare-release.outputs.version }} | |
| TARGET_TRIPLE: ${{ matrix.target.target }} | |
| ARTIFACT_VARIANT: ${{ matrix.feature.label }} | |
| STAGING_DIR_NAME: vs-release-${{ matrix.target.target }}-${{ matrix.feature.label }} | |
| run: ./scripts/github-actions/package_windows.ps1 | |
| - name: Upload workflow artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: vs-v${{ needs.prepare-release.outputs.version }}-${{ matrix.target.target }}-${{ matrix.feature.label }} | |
| path: ${{ env.ARCHIVE_PATH }} | |
| if-no-files-found: error | |
| retention-days: 30 | |
| - name: Upload release asset | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.prepare-release.outputs.tag }} | |
| files: ${{ env.ARCHIVE_PATH }} | |
| publish-crates: | |
| name: Publish crates.io packages | |
| needs: [prepare-release, build-release-artifacts] | |
| runs-on: ubuntu-latest | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| CARGO_REGISTRY_TOKEN_FALLBACK: ${{ vars.CARGO_REGISTRY_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ needs.prepare-release.outputs.tag }} | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Publish workspace crates | |
| shell: bash | |
| run: bash ./scripts/github-actions/publish_crates.sh |