build #118
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: build | |
| on: | |
| workflow_call: | |
| inputs: | |
| ref: | |
| description: Dart SDK git ref | |
| required: true | |
| type: string | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: Dart SDK git ref | |
| required: true | |
| type: string | |
| default: main | |
| jobs: | |
| archive: | |
| runs-on: ${{ matrix.host-arch == 'arm64' && 'ubuntu-24.04-arm' || matrix.host-arch == 'x64' && 'ubuntu-latest' || null }} | |
| container: | |
| image: docker.io/library/debian | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| host-arch: | |
| - x64 | |
| - arm64 | |
| steps: | |
| - name: Install build tools | |
| run: | | |
| apt-get update | |
| apt-get install --no-install-recommends -y ca-certificates curl git python3 | |
| curl -fsSLo /etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list | |
| apt-get update | |
| apt-get install --no-install-recommends -y gh | |
| - name: Fetch Dart SDK | |
| run: | | |
| git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git | |
| export DEPOT_TOOLS_UPDATE=0 PATH=$PWD/depot_tools:$PATH | |
| mkdir dart-sdk | |
| cd dart-sdk | |
| gclient config --name sdk https://dart.googlesource.com/sdk.git@${{ inputs.ref }} | |
| gclient sync --no-history | |
| - name: Get Checked-in Dart SDK Version | |
| id: version | |
| run: | | |
| cd dart-sdk/sdk | |
| echo "version=$(cat tools/sdks/dart-sdk/version)" | tee -a "$GITHUB_OUTPUT" | |
| - name: Fetch Checked-in Dart SDK | |
| run: | | |
| if curl -fsSLO ${{ github.server_url }}/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/dartsdk-linux-${{ matrix.host-arch }}-release.tar.gz; then | |
| gh attestation verify dartsdk-linux-${{ matrix.host-arch }}-release.tar.gz --repo ${{ github.repository }} --signer-workflow ${{ github.repository }}/.github/workflows/build.yml@refs/tags/${{ steps.version.outputs.version }} | |
| rm -rf dart-sdk/sdk/tools/sdks/dart-sdk | |
| tar -xzf dartsdk-linux-${{ matrix.host-arch }}-release.tar.gz -C dart-sdk/sdk/tools/sdks | |
| else | |
| gh workflow run build.yml --repo ${{ github.repository }} --raw-field ref=${{ steps.version.outputs.version }} | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Remove build tools | |
| run: | | |
| cd dart-sdk/sdk | |
| rm -rf buildtools | |
| mkdir -p buildtools/ninja buildtools/sysroot | |
| ln -s /usr/bin/gn buildtools/gn | |
| ln -s /usr/bin/ninja buildtools/ninja/ninja | |
| - name: Archive | |
| run: | | |
| tar -czf dart-${{ inputs.ref }}-${{ matrix.host-arch }}.tar.gz dart-sdk | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dart-${{ inputs.ref }}-${{ matrix.host-arch }} | |
| path: dart-${{ inputs.ref }}-${{ matrix.host-arch }}.tar.gz | |
| if-no-files-found: error | |
| compression-level: 0 | |
| build: | |
| needs: [archive] | |
| runs-on: ${{ matrix.host-arch == 'arm64' && 'ubuntu-24.04-arm' || matrix.host-arch == 'x64' && 'ubuntu-latest' || null }} | |
| permissions: | |
| actions: write | |
| attestations: write | |
| id-token: write | |
| container: | |
| image: docker.io/library/alpine | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - host-arch: arm64 | |
| target-arch: arm | |
| - host-arch: arm64 | |
| target-arch: arm64 | |
| - host-arch: x64 | |
| target-arch: riscv64 | |
| - host-arch: x64 | |
| target-arch: x64 | |
| steps: | |
| - name: Setup node:alpine for JavaScript Actions | |
| uses: dart-musl/setup-node-alpine-for-javascript-actions@v1 | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: dart-${{ inputs.ref }}-${{ matrix.host-arch }} | |
| - name: Unarchive | |
| run: | | |
| tar -xzf dart-${{ inputs.ref }}-${{ matrix.host-arch }}.tar.gz | |
| - name: Verify Checked-in Dart SDK | |
| run: | | |
| cd dart-sdk/sdk | |
| if ! ./tools/sdks/dart-sdk/bin/dart --version; then | |
| apk add --no-cache -- gcompat | |
| ./tools/sdks/dart-sdk/bin/dart --version | |
| fi | |
| - name: Install build tools | |
| run: | | |
| apk add --no-cache -- bash clang curl git gn lld llvm python3 | |
| - name: Install sysroots | |
| run: | | |
| cd dart-sdk/sdk | |
| ./build/linux/alpine_sysroot_scripts/install-sysroot.sh | |
| - name: Build | |
| run: | | |
| cd dart-sdk/sdk | |
| ./tools/build.py --mode release --arch ${{ matrix.target-arch }} --gn-args 'dart_sysroot="alpine"' create_sdk | |
| - name: Archive | |
| run: | | |
| tar -czf dartsdk-linux-${{ matrix.target-arch }}-release.tar.gz -C dart-sdk/sdk/out/Release* -- dart-sdk | |
| find dart-sdk/sdk/out/Release*/exe.stripped \( -name dartaotruntime_product -o -name 'gen_snapshot_product_*' \) -not -name gen_snapshot_product_linux_${{ matrix.target-arch }} -print0 | xargs -0 -n 1 -- sh -c 'cp "$1" "$(basename "$1" | sed -e "s/product/linux_${{ matrix.target-arch }}/")"' -- | |
| - name: Generate artifact attestation | |
| if: github.ref_type == 'tag' | |
| uses: actions/attest-build-provenance@v3 | |
| with: | |
| subject-path: | | |
| dartsdk-linux-${{ matrix.target-arch }}-release.tar.gz | |
| dartaotruntime_linux_${{ matrix.target-arch }} | |
| gen_snapshot_linux_${{ matrix.target-arch }}_* | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dartsdk-linux-${{ matrix.target-arch }}-${{ inputs.ref }} | |
| path: | | |
| dartsdk-linux-${{ matrix.target-arch }}-release.tar.gz | |
| dartaotruntime_linux_${{ matrix.target-arch }} | |
| gen_snapshot_linux_${{ matrix.target-arch }}_* | |
| if-no-files-found: error | |
| compression-level: 0 | |
| tag: | |
| needs: [build] | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| ssh-key: ${{ secrets.DEPLOY_KEY }} | |
| - name: Tag | |
| run: | | |
| if git ls-remote --exit-code --tags https://dart.googlesource.com/sdk.git "${{ inputs.ref }}"; then | |
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| git config user.name github-actions[bot] | |
| if test -n "$(git tag -l ${{ inputs.ref }})"; then | |
| echo "Tag ${{ inputs.ref }} has already been created." | |
| exit 0 | |
| fi | |
| git tag -m ${{ inputs.ref }} ${{ inputs.ref }} | |
| echo "Tagged ${{ inputs.ref }}." | |
| git push origin refs/tags/${{ inputs.ref }} | |
| echo "Pushed tag ${{ inputs.ref }}." | |
| fi |