release.yml (1773B)
1 # Adapted from dzfrias.dev/blog/deploy-rust-cross-platform-github-actions 2 3 name: Release 4 5 on: 6 push: 7 tags: 8 - "[0-9]+.[0-9]+.[0-9]+" 9 10 permissions: 11 contents: write 12 13 jobs: 14 build-and-upload: 15 name: Build and upload 16 runs-on: ${{ matrix.os }} 17 18 strategy: 19 matrix: 20 include: 21 - build: linux 22 os: ubuntu-latest 23 target: x86_64-unknown-linux-musl 24 - build: macos 25 os: macos-latest 26 target: x86_64-apple-darwin 27 - build: windows-gnu 28 os: windows-latest 29 target: x86_64-pc-windows-gnu 30 31 steps: 32 - uses: actions/checkout@v3 33 34 - uses: dtolnay/rust-toolchain@stable 35 with: 36 targets: ${{ matrix.target }} 37 38 - name: Parse version 39 shell: bash 40 run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV 41 42 - name: Build binary 43 run: cargo build --verbose --release --target ${{ matrix.target }} 44 45 - name: Create archive 46 shell: bash 47 run: | 48 dirname="coliru-${{ matrix.target }}" 49 mkdir "$dirname" 50 if [ "${{ matrix.os }}" = "windows-latest" ]; then 51 mv "target/${{ matrix.target }}/release/coliru.exe" "$dirname" 52 else 53 mv "target/${{ matrix.target }}/release/coliru" "$dirname" 54 fi 55 56 if [ "${{ matrix.os }}" = "windows-latest" ]; then 57 7z a "$dirname.zip" "$dirname" 58 echo "ASSET=$dirname.zip" >> $GITHUB_ENV 59 else 60 tar -czf "$dirname.tar.gz" "$dirname" 61 echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV 62 fi 63 64 - name: Create release 65 uses: softprops/action-gh-release@v1 66 with: 67 files: | 68 ${{ env.ASSET }}