name: Release
on:
push:
tags:
- "v*"
permissions: write-all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
extract_version:
name: Extract version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Extract version
id: "version"
run: |
DOTT_VERSION=$(grep '^version' Cargo.toml | awk -F '"' '{ print $2 }')
echo version: $DOTT_VERSION
echo "::set-output name=version::$DOTT_VERSION"
create_release:
name: Create release
needs: ["extract_version"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Create new release
if: ${{ github.ref == 'refs/heads/master' }}
run: |
COMMIT_HASH=$(git rev-list --max-count=1 HEAD)
echo "Creating release: v${{ needs.extract_version.outputs.version }}"
echo "for hash: $COMMIT_HASH"
gh release create v${{ needs.extract_version.outputs.version }} \
-t v${{ needs.extract_version.outputs.version }} \
--notes "Automatically released by CI" \
--prerelease \
--target $COMMIT_HASH
check_nix:
name: Check
runs-on: ubuntu-22.04
steps:
- name: git checkout
uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Set up Rust cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: dott-${{ hashFiles('**/Cargo.lock') }}
- name: Check Nixpkgs inputs
uses: DeterminateSystems/flake-checker-action@v4
with:
check-outdated: false
fail-mode: true
- name: Check formatting
run: |
nix develop --command \
cargo fmt --check
- name: Lint
run: |
nix develop --command \
cargo clippy -- -D warnings
- name: Test
run: |
nix develop --command \
cargo test --release
publish_crate:
name: Publish crate
needs: ["check_nix", "extract_version", "create_release"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Print target version
run: |
echo Publishing version v${{ needs.extract_version.outputs.version }}
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Build
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
run: |
nix develop
cargo build -r
cargo publish --token ${CRATES_TOKEN}
publish_to_aur:
name: Publish to aur
needs: ["check_nix", "extract_version", "create_release"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Print target version
run: |
echo Using version v${{ needs.extract_version.outputs.version }}
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Build binary
id: build_bin
run: |
nix bundle --bundler github:NixOS/bundlers#toArx -o dott
DOTT_PATH=$(readlink -f dott)
echo "dott_path=$DOTT_PATH" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v2
name: "Upload artifacts"
with:
name: Binary
path: |
${{ steps.build-bin.outputs.dott_path }}
- name: Upload artifacts to GH releases
run: |
gh release upload v${{ needs.extract_version.outputs.version }} \
${{steps.build-bin.outputs.dott_path}}
- name: Generate PKGBUILD
run: |
DOTT_CHECKSUM=$(sha512sum ${{steps.build-bin.outputs.dott_path}} | cut -d' ' -f1)
echo $DOTT_CHECKSUM
README_CHECKSUM=$(sha512sum README.md | cut -d' ' -f1)
echo $README_CHECKSUM
RELEASE_TAG=${{ needs.extract_version.outputs.version }} DOTT_CHECKSUM=$DOTT_CHECKSUM README_CHECKSUM=$README_CHECKSUM ./ci/generate-pkgbuild.py
- name: Publish to AUR
uses: KSXGitHub/github-actions-deploy-aur@v2.7.0
with:
pkgname: dott-rs-bin
pkgbuild: ./pkgbuild/dott-rs-bin/PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: v${{ needs.extract_version.outputs.version }}
linux_deb:
name: Linux Debian Release
needs: ["check_nix", "extract_version", "create_release"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Print target version
run: |
echo Using version v${{ needs.extract_version.outputs.version }}
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Build deb packages
run: |
nix develop
cargo install cargo-deb --version 1.34.0
cargo-deb
- uses: actions/upload-artifact@v2
name: "Upload artifacts"
with:
name: Debian Artifacts
path: |
target/debian/dott_${{ needs.extract_version.outputs.version }}_amd64.deb
- name: Upload artifacts to GH releases
run: |
gh release upload v${{ needs.extract_version.outputs.version }} \
target/debian/dott_${{ needs.extract_version.outputs.version }}_amd64.deb