Add github workflows to release and test aiscript #1
Workflow file for this run
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 AIScript | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| build: | |
| name: Build AIScript (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: aiscript | |
| asset_name: aiscript-linux-x86_64 | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact_name: aiscript | |
| asset_name: aiscript-macos-x86_64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| artifact_name: aiscript | |
| asset_name: aiscript-macos-arm64 | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact_name: aiscript.exe | |
| asset_name: aiscript-windows-x86_64.exe | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Setup Rust toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: ${{ matrix.target }} | |
| override: true | |
| - name: Build binary | |
| uses: actions-rs/cargo@v1 | |
| with: | |
| command: build | |
| args: --release --target ${{ matrix.target }} | |
| - name: Move binary to final location | |
| shell: bash | |
| run: | | |
| mkdir -p dist | |
| if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
| cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} dist/${{ matrix.asset_name }} | |
| else | |
| cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} dist/${{ matrix.asset_name }} | |
| chmod +x dist/${{ matrix.asset_name }} | |
| fi | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: ${{ matrix.asset_name }} | |
| path: dist/${{ matrix.asset_name }} | |
| if-no-files-found: error | |
| release: | |
| needs: build | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v3 | |
| with: | |
| path: dist | |
| # Add the install.sh script to the release | |
| - name: Prepare install script | |
| run: | | |
| cp install.sh dist/ | |
| chmod +x dist/install.sh | |
| # Generate checksums for all artifacts | |
| - name: Generate checksums | |
| run: | | |
| cd dist | |
| find . -type f -not -path "*/\.*" | grep -v "checksums.txt" | xargs -I{} shasum -a 256 {} > checksums.txt | |
| cat checksums.txt | |
| - name: Create release | |
| id: create_release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| dist/aiscript-linux-x86_64/aiscript-linux-x86_64 | |
| dist/aiscript-macos-x86_64/aiscript-macos-x86_64 | |
| dist/aiscript-macos-arm64/aiscript-macos-arm64 | |
| dist/aiscript-windows-x86_64.exe/aiscript-windows-x86_64.exe | |
| dist/install.sh | |
| dist/checksums.txt | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |