|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + tags: |
| 8 | + - '**' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - '**' |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + name: Build |
| 16 | + |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - arch: x64 |
| 23 | + builds-on: linux/amd64 |
| 24 | + runs-on: linux/amd64 |
| 25 | + - arch: ia32 |
| 26 | + builds-on: linux/amd64 |
| 27 | + runs-on: linux/386 |
| 28 | + - arch: arm64 |
| 29 | + builds-on: linux/arm64 |
| 30 | + runs-on: linux/arm64 |
| 31 | + - arch: arm |
| 32 | + builds-on: linux/amd64 |
| 33 | + runs-on: linux/arm/v7 |
| 34 | + |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v3 |
| 37 | + with: |
| 38 | + repository: 'sass/dart-sass-embedded' |
| 39 | + ref: ${{ startsWith(github.ref, 'refs/tags/') && github.ref || '' }} |
| 40 | + |
| 41 | + - name: Configure |
| 42 | + id: configure |
| 43 | + run: | |
| 44 | + NAME=${NAME:-$(yq .name pubspec.yaml)} |
| 45 | + VERSION=${VERSION:-$(yq .version pubspec.yaml)} |
| 46 | + ARCHIVE=$NAME-$VERSION-linux-${{ matrix.arch }}.tar.gz |
| 47 | + echo "name=$NAME" | tee -a $GITHUB_OUTPUT |
| 48 | + echo "version=$VERSION" | tee -a $GITHUB_OUTPUT |
| 49 | + echo "archive=$ARCHIVE" | tee -a $GITHUB_OUTPUT |
| 50 | +
|
| 51 | + - name: Set up QEMU |
| 52 | + uses: docker/setup-qemu-action@v2 |
| 53 | + |
| 54 | + - name: Compile Protobuf |
| 55 | + run: | |
| 56 | + docker run --rm -i \ |
| 57 | + --volume $PWD:$PWD \ |
| 58 | + --workdir $PWD \ |
| 59 | + docker.io/library/dart <<'EOF' |
| 60 | + set -e |
| 61 | + apt-get update |
| 62 | + apt-get install -y protobuf-compiler |
| 63 | + dart pub get |
| 64 | + dart run grinder protobuf |
| 65 | + EOF |
| 66 | +
|
| 67 | + - name: Build |
| 68 | + run: | |
| 69 | + docker run --rm -i \ |
| 70 | + --platform ${{ matrix.builds-on }} \ |
| 71 | + --volume $PWD:$PWD \ |
| 72 | + --workdir $PWD \ |
| 73 | + ghcr.io/dart-musl/dart <<'EOF' |
| 74 | + set -e |
| 75 | + dart pub get |
| 76 | + dart run grinder pkg-standalone-linux-${{ matrix.arch }} |
| 77 | + EOF |
| 78 | +
|
| 79 | + - name: Fix Dart Runtime |
| 80 | + if: matrix.builds-on != matrix.runs-on |
| 81 | + run: | |
| 82 | + docker run --rm -i \ |
| 83 | + --platform ${{ matrix.runs-on }} \ |
| 84 | + --volume $PWD:$PWD \ |
| 85 | + --workdir $PWD \ |
| 86 | + ghcr.io/dart-musl/dart <<'EOF' |
| 87 | + set -e |
| 88 | + cd build |
| 89 | + tar -xzf ${{ steps.configure.outputs.archive }} |
| 90 | + cp $DART_SDK/bin/dart ${{ steps.configure.outputs.name }}/src/dart |
| 91 | + tar -czf ${{ steps.configure.outputs.archive }} ${{ steps.configure.outputs.name }} |
| 92 | + EOF |
| 93 | +
|
| 94 | + - name: Upload Artifact |
| 95 | + uses: actions/upload-artifact@v3 |
| 96 | + with: |
| 97 | + name: build-${{ matrix.arch }} |
| 98 | + path: build/${{ steps.configure.outputs.archive }} |
| 99 | + if-no-files-found: error |
| 100 | + |
| 101 | + release: |
| 102 | + name: Release |
| 103 | + |
| 104 | + if: github.event.repository.fork == false && startsWith(github.ref, 'refs/tags/') |
| 105 | + |
| 106 | + needs: [build] |
| 107 | + |
| 108 | + runs-on: ubuntu-latest |
| 109 | + |
| 110 | + permissions: |
| 111 | + contents: write |
| 112 | + |
| 113 | + steps: |
| 114 | + - name: Download Artifact |
| 115 | + uses: actions/download-artifact@v3 |
| 116 | + with: |
| 117 | + name: build-x64 |
| 118 | + |
| 119 | + - name: Download Artifact |
| 120 | + uses: actions/download-artifact@v3 |
| 121 | + with: |
| 122 | + name: build-ia32 |
| 123 | + |
| 124 | + - name: Download Artifact |
| 125 | + uses: actions/download-artifact@v3 |
| 126 | + with: |
| 127 | + name: build-arm64 |
| 128 | + |
| 129 | + - name: Download Artifact |
| 130 | + uses: actions/download-artifact@v3 |
| 131 | + with: |
| 132 | + name: build-arm |
| 133 | + |
| 134 | + - name: Release |
| 135 | + uses: softprops/action-gh-release@v1 |
| 136 | + with: |
| 137 | + files: | |
| 138 | + *.tar.gz |
0 commit comments