From cbd4800e6b3e6de4c5a1fd81ce0887d1115808f1 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Tue, 2 May 2023 00:07:33 -0700 Subject: [PATCH] Add github actions for testing --- .github/workflows/cargo-test-publish.yaml | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/cargo-test-publish.yaml diff --git a/.github/workflows/cargo-test-publish.yaml b/.github/workflows/cargo-test-publish.yaml new file mode 100644 index 0000000..2e21b5c --- /dev/null +++ b/.github/workflows/cargo-test-publish.yaml @@ -0,0 +1,50 @@ +name: Build and Release +on: [ push ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout Repo + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Generate changelog info + run: | + # todo: make this part of yaclog! + pip install yaclog~=1.1 + yaclog show + echo "VERSION_TITLE=$(yaclog show -n)" >> $GITHUB_ENV + echo "$(yaclog show -mb)" >> /tmp/RELEASE.md + + - name: Setup Rust toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: rustfmt + + - name: Run Checks + run: | + cargo check + cargo fmt --check + + - name: Run Unit Tests + run: cargo test + + - name: Publish to Crates.io + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + run: cargo publish --token ${{ secrets.CARGO_TOKEN }} + + - name: Publish to Github + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: softprops/action-gh-release@v1 + with: + name: Version ${{ env.VERSION_TITLE }} + body_path: /tmp/RELEASE.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}