Merge pull request #163 from xsnippet/clippy-warnings #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
branches: [ master ] | |
tags: | |
- "v*" | |
env: | |
CARGO_TERM_COLOR: always | |
RUSTFLAGS: -Dwarnings | |
RUST_BACKTRACE: 1 | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
create_release: | |
runs-on: ubuntu-latest | |
outputs: | |
release_tag: ${{ steps.create_release.outputs.release_tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: create_release | |
run: | | |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
echo "release_tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
gh release create --generate-notes "${GITHUB_REF#refs/tags/}" | |
else | |
echo "release_tag=nightly" >> $GITHUB_OUTPUT | |
gh release delete --cleanup-tag --yes nightly | |
gh release create --generate-notes --prerelease --title "Development Build" nightly | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_REPO: ${{ env.GITHUB_REPOSITORY }} | |
build_assets: | |
needs: create_release | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macos-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: Setup PostgreSQL | |
uses: ikalnytskyi/action-setup-postgres@v1 | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release | |
- run: | | |
rustc --print cfg | grep = > rustc.vars | |
source rustc.vars | |
pushd target/release | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
export ASSET_NAME="xsnippet-api-${target_arch}-${target_os}.exe.7z" | |
7z a $ASSET_NAME xsnippet-api.exe | |
else | |
export ASSET_NAME="xsnippet-api-${target_arch}-${target_os}.gz" | |
tar cvzf $ASSET_NAME xsnippet-api | |
fi | |
gh release upload $RELEASE_TAG $ASSET_NAME | |
popd | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_REPO: ${{ env.GITHUB_REPOSITORY }} | |
RELEASE_TAG: ${{ needs.create_release.outputs.release_tag }} |