diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f86185..c65ff14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,3 @@ -# "Borrowed" with permission from https://github.com/Jonxslays/piston_rs/blob/master/.github/workflows/ci.yml. -# Thanks bud! - name: CI on: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..eec7f41 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Release + +on: + release: + types: [published] + +jobs: + check-version: + name: Check version + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Check version + run: | + [[ $(grep -m 1 -oP 'version = "(.*)"' Cargo.toml | sed -rn 's/.*"(.*)"/v\1/p') == ${{ github.event.release.tag_name }} ]] + + publish: + name: Publish release + + runs-on: ubuntu-latest + needs: check-version + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Rust (stable) + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Login to crates.io + env: + TOKEN: ${{ secrets.CRATES_IO_TOKEN }} + + run: cargo login $TOKEN + + - name: Publish dry-run + run: cargo publish --dry-run + + - name: Publish + run: cargo publish