diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f9f998..95124eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,24 +1,45 @@ -name: Cargo Build & Test +name: Deploy on: - release: - types: [published] + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" jobs: - publish: - name: Publish to crates.io + build-and-upload: + name: Build and upload + runs-on: ${{ matrix.os }} - runs-on: ubuntu-latest - environment: crates.io + strategy: + matrix: + # You can add more, for any target you'd like! + include: + - build: linux + os: ubuntu-latest + target: x86_64-unknown-linux-musl + + - build: macos + os: macos-latest + target: x86_64-apple-darwin steps: - - uses: actions/checkout@v3 - - uses: swatinem/rust-cache@v2 - - - name: Publish - # https://doc.rust-lang.org/cargo/reference/config.html?highlight=CARGO_REGISTRY_TOKEN#credentials - run: > - cargo workspaces publish - --verbose - --allow-branch * - --token ${{ secrets.CARGO_REGISTRY_TOKEN }} + - name: Checkout + uses: actions/checkout@v3 + + - name: Get the release version from the tag + shell: bash + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.target }} + override: true + + - name: Install Rust + run: rustup target add ${{ matrix.target }} + + - name: Publish to Cargo + run: | + cargo workspaces publish --verbose --allow-branch * --token ${{ secrets.CARGO_REGISTRY_TOKEN }}