Merge pull request #160 from xsnippet/gh #43
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: ${{ github.event.repository.name }} | |
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 | |
7z a xsnippet-api.exe.7z xsnippet-api.exe | |
gh release upload "$RELEASE_TAG" "xsnippet-api.exe.7z#xsnippet-api-${target_arch}-${target_os}.exe.7z" | |
else | |
tar cvzf xsnippet-api.gz xsnippet-api | |
gh release upload "$RELEASE_TAG" "xsnippet-api.gz#xsnippet-api-${target_arch}-${target_os}.gz" | |
fi | |
popd | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_REPO: ${{ github.event.repository.name }} | |
RELEASE_TAG: ${{ needs.create_release.outputs.release_tag }} |