|
| 1 | +name: Compile and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ stable ] |
| 6 | + paths: |
| 7 | + - bin/** |
| 8 | + - lib/** |
| 9 | + - .github/workflows/docrunner_release.yml |
| 10 | + - pubspec.yaml |
| 11 | + - CHANGELOG.md |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + os: [ubuntu-20.04, windows-2019, macOS-10.15] |
| 18 | + |
| 19 | + name: Build binary on ${{ matrix.os }} |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v2 |
| 24 | + |
| 25 | + # Note: This workflow uses the latest stable version of the Dart SDK. |
| 26 | + # You can specify other versions if desired, see documentation here: |
| 27 | + # https://github.com/dart-lang/setup-dart/blob/main/README.md |
| 28 | + # - uses: dart-lang/setup-dart@v1 |
| 29 | + - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 |
| 30 | + |
| 31 | + - name: Install dependencies |
| 32 | + run: dart pub get |
| 33 | + |
| 34 | + - name: Build dart files |
| 35 | + run: dart run build_runner build |
| 36 | + |
| 37 | + - name: Create release directory |
| 38 | + run: mkdir -p target/release |
| 39 | + |
| 40 | + - name: Compile code (linux and mac) |
| 41 | + if: | |
| 42 | + startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macOS') |
| 43 | + run: dart compile exe bin/main.dart -o target/release/docrunner |
| 44 | + |
| 45 | + - name: Compile code (windows) |
| 46 | + if: | |
| 47 | + startsWith(matrix.os, 'windows') |
| 48 | + run: dart compile exe bin/main.dart -o target/release/docrunner.exe |
| 49 | + |
| 50 | + - name: Pre-release (linux) |
| 51 | + if: | |
| 52 | + startsWith(matrix.os, 'ubuntu') |
| 53 | + run: | |
| 54 | + cd target/release |
| 55 | + zip -r docrunner-x86_64-unknown-linux-gnu.zip docrunner |
| 56 | + |
| 57 | + - name: Pre-release (mac) |
| 58 | + if: | |
| 59 | + startsWith(matrix.os, 'macOS') |
| 60 | + run: | |
| 61 | + cd target/release |
| 62 | + zip -r docrunner-x86_64-apple-darwin.zip docrunner |
| 63 | + |
| 64 | + - name: Pre-release (windows) |
| 65 | + if: | |
| 66 | + startsWith(matrix.os, 'windows') |
| 67 | + run: | |
| 68 | + Compress-Archive -CompressionLevel Optimal -Force -Path target/release/docrunner.exe -DestinationPath target/release/docrunner-x86_64-pc-windows-msvc.zip |
| 69 | +
|
| 70 | + - name: Upload Artifact (linux) |
| 71 | + if: | |
| 72 | + startsWith(matrix.os, 'ubuntu') |
| 73 | + uses: actions/upload-artifact@v3.1.0 |
| 74 | + with: |
| 75 | + name: docrunner-x86_64-unknown-linux-gnu |
| 76 | + path: target/release/docrunner-x86_64-unknown-linux-gnu.zip |
| 77 | + |
| 78 | + - name: Upload Artifact (mac) |
| 79 | + if: | |
| 80 | + startsWith(matrix.os, 'macOS') |
| 81 | + uses: actions/upload-artifact@v3.1.0 |
| 82 | + with: |
| 83 | + name: docrunner-x86_64-apple-darwin |
| 84 | + path: target/release/docrunner-x86_64-apple-darwin.zip |
| 85 | + |
| 86 | + - name: Upload Artifact (windows) |
| 87 | + if: | |
| 88 | + startsWith(matrix.os, 'windows') |
| 89 | + uses: actions/upload-artifact@v3.1.0 |
| 90 | + with: |
| 91 | + name: docrunner-x86_64-pc-windows-msvc |
| 92 | + path: target/release/docrunner-x86_64-pc-windows-msvc.zip |
| 93 | + |
| 94 | + |
| 95 | + release: |
| 96 | + name: Create GitHub release |
| 97 | + needs: build |
| 98 | + runs-on: ubuntu-latest |
| 99 | + steps: |
| 100 | + - uses: actions/checkout@v2 |
| 101 | + |
| 102 | + - name: Download all artifacts |
| 103 | + uses: actions/download-artifact@v3.0.0 |
| 104 | + |
| 105 | + - name: Get release name |
| 106 | + uses: KJ002/read-yaml@v1.4 |
| 107 | + id: name |
| 108 | + with: |
| 109 | + file: ./pubspec.yaml |
| 110 | + key-path: '["name"]' |
| 111 | + |
| 112 | + - name: Get version number for release |
| 113 | + uses: KJ002/read-yaml@v1.4 |
| 114 | + id: version |
| 115 | + with: |
| 116 | + file: ./pubspec.yaml |
| 117 | + key-path: '["version"]' |
| 118 | + |
| 119 | + - name: Get release notes |
| 120 | + uses: ./actions/changelog-action |
| 121 | + id: changelog |
| 122 | + with: |
| 123 | + file: './CHANGELOG.md' |
| 124 | + |
| 125 | + - name: Upload release to GitHub |
| 126 | + uses: softprops/action-gh-release@v0.1.14 |
| 127 | + with: |
| 128 | + name: ${{ steps.name.outputs.data }} ${{ steps.version.outputs.data }} |
| 129 | + tag_name: ${{ steps.version.outputs.data }} |
| 130 | + body: ${{ steps.changelog.outputs.data }} |
| 131 | + files: | |
| 132 | + docrunner-x86_64-pc-windows-msvc/docrunner-x86_64-pc-windows-msvc.zip |
| 133 | + docrunner-x86_64-unknown-linux-gnu/docrunner-x86_64-unknown-linux-gnu.zip |
| 134 | + docrunner-x86_64-apple-darwin/docrunner-x86_64-apple-darwin.zip |
0 commit comments