|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + name: Building for ${{ matrix.config.os }} |
| 15 | + runs-on: ${{ matrix.config.os }} |
| 16 | + |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + config: |
| 21 | + - os: ubuntu-latest |
| 22 | + rust_target: x86_64-unknown-linux-gnu |
| 23 | + ext: "" |
| 24 | + - os: macos-latest |
| 25 | + rust_target: x86_64-apple-darwin |
| 26 | + ext: "" |
| 27 | + - os: macos-latest |
| 28 | + rust_target: aarch64-apple-darwin |
| 29 | + ext: "" |
| 30 | + - os: windows-latest |
| 31 | + rust_target: x86_64-pc-windows-msvc |
| 32 | + ext: ".exe" |
| 33 | + |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v3 |
| 36 | + - name: "Setup Rust" |
| 37 | + uses: dtolnay/rust-toolchain@stable |
| 38 | + with: |
| 39 | + targets: ${{ matrix.config.rust_target }} |
| 40 | + - uses: Swatinem/rust-cache@v2 |
| 41 | + with: |
| 42 | + key: ${{ matrix.config.rust_target }} |
| 43 | + - name: Cargo Build |
| 44 | + uses: actions-rs/cargo@v1 |
| 45 | + with: |
| 46 | + command: build |
| 47 | + args: --release --target ${{ matrix.config.rust_target }} |
| 48 | + - name: Create Assets |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + BINARY_FILENAME="target/${{ matrix.config.rust_target }}/release/tyedev${{ matrix.config.ext }}" |
| 52 | + VERSION="${GITHUB_REF#refs/tags/v}" |
| 53 | + RELEASE_NAME=tyedev-${VERSION}-${{ matrix.config.rust_target }} |
| 54 | + mkdir "${RELEASE_NAME}" |
| 55 | + cp LICENSE.txt README.md "${BINARY_FILENAME}" "${RELEASE_NAME}" |
| 56 | + tar -cvzf "${RELEASE_NAME}.tar.gz" "${RELEASE_NAME}" |
| 57 | + if [[ ${{ runner.os }} == 'Windows' ]]; then |
| 58 | + certutil -hashfile "${RELEASE_NAME}.tar.gz" sha256 | grep -E '[A-Fa-f0-9]{64}' > "${RELEASE_NAME}.sha256" |
| 59 | + else |
| 60 | + shasum -a 256 "${RELEASE_NAME}.tar.gz" > "${RELEASE_NAME}.sha256" |
| 61 | + fi |
| 62 | + - name: Release Assets |
| 63 | + uses: softprops/action-gh-release@v1 |
| 64 | + with: |
| 65 | + files: | |
| 66 | + tyedev-*.tar.gz |
| 67 | + tyedev-*.sha256 |
| 68 | + env: |
| 69 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + |
| 71 | + publish-crate: |
| 72 | + name: Publishing to crates.io |
| 73 | + runs-on: ubuntu-latest |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v3 |
| 76 | + - name: Install Rust Toolchain |
| 77 | + uses: dtolnay/rust-toolchain@stable |
| 78 | + - uses: Swatinem/rust-cache@v2 |
| 79 | + - run: cargo publish |
| 80 | + env: |
| 81 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
0 commit comments