name: CI on: push: branches: ['**'] tags: ['v*'] pull_request: branches: [main] env: RUSTC_WRAPPER: sccache SCCACHE_BUCKET: sccache SCCACHE_ENDPOINT: http://caveman.kosherinata.internal:9000 SCCACHE_REGION: auto SCCACHE_S3_USE_SSL: "false" AWS_ACCESS_KEY_ID: ${{ secrets.SCCACHE_S3_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.SCCACHE_S3_SECRET_KEY }} jobs: check: name: Format, lint, build, test runs-on: fedora steps: - uses: actions/checkout@v4 - name: Ensure sccache with S3 support run: | if sccache --version 2>/dev/null && sccache --show-stats 2>/dev/null; then echo "sccache with S3 support already installed" else cargo install sccache --features s3 --locked fi - name: Check formatting run: cargo fmt --check --all - name: Clippy run: cargo clippy --workspace -- -D warnings - name: Build run: cargo build --workspace - name: Test run: cargo test --workspace - name: Show sccache stats run: sccache --show-stats srpm-cortex: name: Build cortex SRPM runs-on: fedora needs: check if: startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/checkout@v4 - name: Determine version id: version run: | VERSION="${GITHUB_REF#refs/tags/v}" echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT" - name: Stamp version run: | VERSION="${{ steps.version.outputs.VERSION }}" sed -i '/\[workspace\.package\]/,/\[/{ s/^version = ".*"/version = "'"${VERSION}"'"/ }' Cargo.toml sed -i "s/^Version:.*/Version: ${VERSION}/" cortex.spec - name: Generate source tarball run: | set -ex VERSION="${{ steps.version.outputs.VERSION }}" tar czf /tmp/cortex-${VERSION}.tar.gz \ --transform "s,^\.,cortex-${VERSION}," \ --exclude='./target' \ --exclude='./.git' \ --exclude='*.tar.gz' \ --exclude='*.src.rpm' \ . mv /tmp/cortex-${VERSION}.tar.gz . - name: Vendor Rust dependencies run: | VERSION="${{ steps.version.outputs.VERSION }}" cargo vendor vendor/ tar czf cortex-${VERSION}-vendor.tar.gz vendor/ rm -rf vendor/ - name: Build SRPM run: | rpmbuild -bs cortex.spec \ --define "_sourcedir $(pwd)" \ --define "_srcrpmdir $(pwd)" - name: Upload SRPM artifact uses: actions/upload-artifact@v3 with: name: srpm-cortex path: '*.src.rpm' srpm-neuron: name: Build neuron SRPM runs-on: fedora needs: check if: startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/checkout@v4 - name: Determine version id: version run: | VERSION="${GITHUB_REF#refs/tags/v}" echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT" - name: Stamp version run: | VERSION="${{ steps.version.outputs.VERSION }}" sed -i '/\[workspace\.package\]/,/\[/{ s/^version = ".*"/version = "'"${VERSION}"'"/ }' Cargo.toml sed -i "s/^Version:.*/Version: ${VERSION}/" neuron.spec - name: Generate source tarball run: | set -ex VERSION="${{ steps.version.outputs.VERSION }}" tar czf /tmp/neuron-${VERSION}.tar.gz \ --transform "s,^\.,neuron-${VERSION}," \ --exclude='./target' \ --exclude='./.git' \ --exclude='*.tar.gz' \ --exclude='*.src.rpm' \ . mv /tmp/neuron-${VERSION}.tar.gz . - name: Vendor Rust dependencies run: | VERSION="${{ steps.version.outputs.VERSION }}" cargo vendor vendor/ tar czf neuron-${VERSION}-vendor.tar.gz vendor/ rm -rf vendor/ - name: Build SRPM run: | rpmbuild -bs neuron.spec \ --define "_sourcedir $(pwd)" \ --define "_srcrpmdir $(pwd)" - name: Upload SRPM artifact uses: actions/upload-artifact@v3 with: name: srpm-neuron path: '*.src.rpm' copr-cortex: name: Publish cortex to COPR runs-on: fedora needs: srpm-cortex steps: - name: Download SRPM uses: actions/download-artifact@v3 with: name: srpm-cortex - name: Configure copr-cli run: | mkdir -p ~/.config echo "${{ secrets.COPR_CONFIG }}" > ~/.config/copr - name: Submit build to COPR run: copr-cli build helexa/cortex *.src.rpm copr-neuron: name: Publish neuron to COPR runs-on: fedora needs: srpm-neuron steps: - name: Download SRPM uses: actions/download-artifact@v3 with: name: srpm-neuron - name: Configure copr-cli run: | mkdir -p ~/.config echo "${{ secrets.COPR_CONFIG }}" > ~/.config/copr - name: Submit build to COPR run: copr-cli build helexa/neuron *.src.rpm bump-version: name: Bump version in source runs-on: fedora needs: [copr-cortex, copr-neuron] steps: - uses: actions/checkout@v4 - name: Stamp version and push env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | VERSION="${GITHUB_REF#refs/tags/v}" sed -i '/\[workspace\.package\]/,/\[/{ s/^version = ".*"/version = "'"${VERSION}"'"/ }' Cargo.toml sed -i "s/^Version:.*/Version: ${VERSION}/" cortex.spec sed -i "s/^Version:.*/Version: ${VERSION}/" neuron.spec cargo check --workspace 2>/dev/null || true git config user.name "Gitea Actions" git config user.email "actions@git.lair.cafe" git add Cargo.toml Cargo.lock cortex.spec neuron.spec if git diff --cached --quiet; then echo "Version already at ${VERSION}" else git commit -m "chore: bump version to ${VERSION}" git remote set-url origin "https://gitea-actions:${GITEA_TOKEN}@git.lair.cafe/helexa/cortex.git" git push origin HEAD:main fi