|
| 1 | +name: Release AIScript |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Build AIScript (${{ matrix.os }}) |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - os: ubuntu-latest |
| 16 | + target: x86_64-unknown-linux-gnu |
| 17 | + artifact_name: aiscript |
| 18 | + asset_name: aiscript-linux-x86_64 |
| 19 | + - os: macos-latest |
| 20 | + target: x86_64-apple-darwin |
| 21 | + artifact_name: aiscript |
| 22 | + asset_name: aiscript-macos-x86_64 |
| 23 | + - os: macos-latest |
| 24 | + target: aarch64-apple-darwin |
| 25 | + artifact_name: aiscript |
| 26 | + asset_name: aiscript-macos-arm64 |
| 27 | + - os: windows-latest |
| 28 | + target: x86_64-pc-windows-msvc |
| 29 | + artifact_name: aiscript.exe |
| 30 | + asset_name: aiscript-windows-x86_64.exe |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout code |
| 34 | + uses: actions/checkout@v3 |
| 35 | + |
| 36 | + - name: Setup Rust toolchain |
| 37 | + uses: actions-rs/toolchain@v1 |
| 38 | + with: |
| 39 | + toolchain: stable |
| 40 | + target: ${{ matrix.target }} |
| 41 | + override: true |
| 42 | + |
| 43 | + - name: Build binary |
| 44 | + uses: actions-rs/cargo@v1 |
| 45 | + with: |
| 46 | + command: build |
| 47 | + args: --release --target ${{ matrix.target }} |
| 48 | + |
| 49 | + - name: Move binary to final location |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + mkdir -p dist |
| 53 | + if [ "${{ matrix.os }}" = "windows-latest" ]; then |
| 54 | + cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} dist/${{ matrix.asset_name }} |
| 55 | + else |
| 56 | + cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} dist/${{ matrix.asset_name }} |
| 57 | + chmod +x dist/${{ matrix.asset_name }} |
| 58 | + fi |
| 59 | +
|
| 60 | + - name: Upload artifact |
| 61 | + uses: actions/upload-artifact@v3 |
| 62 | + with: |
| 63 | + name: ${{ matrix.asset_name }} |
| 64 | + path: dist/${{ matrix.asset_name }} |
| 65 | + if-no-files-found: error |
| 66 | + |
| 67 | + release: |
| 68 | + needs: build |
| 69 | + name: Create GitHub Release |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - name: Checkout code |
| 73 | + uses: actions/checkout@v3 |
| 74 | + |
| 75 | + - name: Download artifacts |
| 76 | + uses: actions/download-artifact@v3 |
| 77 | + with: |
| 78 | + path: dist |
| 79 | + |
| 80 | + # Add the install.sh script to the release |
| 81 | + - name: Prepare install script |
| 82 | + run: | |
| 83 | + cp install.sh dist/ |
| 84 | + chmod +x dist/install.sh |
| 85 | +
|
| 86 | + # Generate checksums for all artifacts |
| 87 | + - name: Generate checksums |
| 88 | + run: | |
| 89 | + cd dist |
| 90 | + find . -type f -not -path "*/\.*" | grep -v "checksums.txt" | xargs -I{} shasum -a 256 {} > checksums.txt |
| 91 | + cat checksums.txt |
| 92 | +
|
| 93 | + - name: Create release |
| 94 | + id: create_release |
| 95 | + uses: softprops/action-gh-release@v1 |
| 96 | + with: |
| 97 | + files: | |
| 98 | + dist/aiscript-linux-x86_64/aiscript-linux-x86_64 |
| 99 | + dist/aiscript-macos-x86_64/aiscript-macos-x86_64 |
| 100 | + dist/aiscript-macos-arm64/aiscript-macos-arm64 |
| 101 | + dist/aiscript-windows-x86_64.exe/aiscript-windows-x86_64.exe |
| 102 | + dist/install.sh |
| 103 | + dist/checksums.txt |
| 104 | + draft: false |
| 105 | + prerelease: false |
| 106 | + generate_release_notes: true |
| 107 | + env: |
| 108 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments