mirror of
https://github.com/theopfr/somo.git
synced 2025-06-10 01:33:32 +03:00
103 lines
3.0 KiB
YAML
103 lines
3.0 KiB
YAML
name: Test, Build and Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUST_BACKTRACE: 1
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Run tests
|
|
run: cargo test
|
|
|
|
version-check:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
bump_type: ${{ steps.check_version.outputs.bump_type }}
|
|
new_version: ${{ steps.new_version.outputs.version }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get new version
|
|
id: new_version
|
|
run: echo ::set-output name=version::$(grep -Po '^version = \"\K[^\"]+' Cargo.toml)
|
|
|
|
- name: Get previous version
|
|
id: previous_version
|
|
run: echo ::set-output name=version::$(git describe --tags --abbrev=0 || echo '0.0.0')
|
|
|
|
- name: Check version
|
|
id: check_version
|
|
run: |
|
|
python .github/version_check.py ${{ steps.previous_version.outputs.version }} ${{ steps.new_version.outputs.version }}
|
|
echo "${{ github.event_name}} ${{ github.ref }}"
|
|
|
|
build_and_release:
|
|
needs: version-check
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.version-check.outputs.bump_type != 'patch'
|
|
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Extract version from Cargo.toml
|
|
id: version
|
|
run: echo "version=$(grep -Po '^version = \"\K[^\"]+' Cargo.toml)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Build and package
|
|
run: |
|
|
cargo build --release
|
|
cargo install cargo-deb
|
|
cargo deb --output target/debian/somo-${{ steps.version.outputs.version }}.deb
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: somo-${{ steps.version.outputs.version }}-${{ github.run_number }}-${{ github.sha }}.deb
|
|
path: target/debian/somo-${{ steps.version.outputs.version }}.deb
|
|
|
|
- name: Publish to Crates.io
|
|
run: cargo publish
|
|
env:
|
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
|
|
|
|
- name: Create Release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: v${{ steps.version.outputs.version }}
|
|
release_name: 🎉 Somo Release ${{ steps.version.outputs.version }}
|
|
draft: false
|
|
prerelease: false
|
|
id: create_release
|
|
|
|
- name: Upload Release Asset
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: target/debian/somo-${{ steps.version.outputs.version }}.deb
|
|
asset_name: somo-${{ steps.version.outputs.version }}-${{ github.run_number }}-${{ github.sha }}.deb
|
|
asset_content_type: application/x-debian-package
|