Skip to content

Bump rust from 1.94-bookworm to 1.95-bookworm #292

Bump rust from 1.94-bookworm to 1.95-bookworm

Bump rust from 1.94-bookworm to 1.95-bookworm #292

Workflow file for this run

name: CI/CD
on:
# By default, a workflow only runs when a pull_request event's activity type is opened, synchronize, or reopened.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
# So we add default event types and ready_for_review type here.
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
push:
branches:
- main
tags:
- v*
env:
RUST_BACKTRACE: full
CARGO_TERM_COLOR: always
jobs:
ci:
if: github.event.pull_request.draft == false
name: Run CI tasks
timeout-minutes: 20
runs-on: ubuntu-latest-32core
steps:
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # Latest
with:
toolchain: stable
components: rustfmt,clippy
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
- name: Check "cargo fmt"
run: cargo fmt -- --check
- name: Run "cargo check"
run: cargo check --locked --all-features --all-targets
- name: Run "cargo clippy"
run: cargo clippy --locked --all-features -- -D warnings
- name: Run "cargo test"
run: cargo test --locked --verbose --all-targets --all-features
crate-metadata:
if: startsWith(github.ref, 'refs/tags/v')
timeout-minutes: 5
name: Extract crate metadata
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # Latest
with:
toolchain: stable
- name: Extract crate information
id: crate-metadata
shell: bash
run: |
crate_version="$(cargo metadata --no-deps --format-version 1 | jq -r '"v" + .packages[0].version')"
if [ "${{ github.ref_name }}" != "${crate_version}" ]; then
echo "Tag does not match version in Cargo.toml: ${{ github.ref_name }} != ${crate_version}"
exit 1
fi
cargo metadata --no-deps --format-version 1 | jq -r '"name=" + .packages[0].name' | tee -a $GITHUB_OUTPUT
cargo metadata --no-deps --format-version 1 | jq -r '"version=" + .packages[0].version' | tee -a $GITHUB_OUTPUT
cargo metadata --no-deps --format-version 1 | jq -r '"msrv=" + .packages[0].rust_version' | tee -a $GITHUB_OUTPUT
outputs:
name: ${{ steps.crate-metadata.outputs.name }}
version: ${{ steps.crate-metadata.outputs.version }}
msrv: ${{ steps.crate-metadata.outputs.msrv }}
build-release:
name: Build and release binary
if: startsWith(github.ref, 'refs/tags/v')
timeout-minutes: 120
needs:
- ci
- crate-metadata
permissions:
contents: write
env:
BUILD_CMD: cargo
runs-on: ${{ matrix.job.runner }}
strategy:
fail-fast: false
matrix:
job:
# To sort the matrix, use inline syntax.
- { target: aarch64-apple-darwin, runner: macos-14-xlarge }
steps:
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # Latest
with:
toolchain: stable
targets: ${{ matrix.job.target }}
- if: ${{ contains(matrix.job.os, 'macos')}}
run: brew install openssl@3.0
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Build release binary
run: $BUILD_CMD build --release --locked --verbose --target=${{ matrix.job.target }}
- name: Archive release binary
run: |
tar --create --gzip --verbose --file=${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz --directory=target/${{ matrix.job.target }}/release ${{ needs.crate-metadata.outputs.name }}
- name: Install coreutils for macOS runner
if: ${{ contains(matrix.job.runner, 'macos')}}
run: brew install coreutils
- name: Calculate checksum
run: |
sha256sum ${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz > ${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz.sha256
- name: Upload release binary
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # v2.3.3
with:
draft: true # For immutable release.
files: |
${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz
${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz.sha256
# refs:
# - https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
# - https://github.com/docker/metadata-action#semver
build-release-docker:
name: Build and push Docker image and release binary
if: startsWith(github.ref, 'refs/tags/v')
timeout-minutes: 120
needs:
- crate-metadata
- ci
runs-on: ubuntu-latest-64core
permissions:
contents: write
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
strategy:
fail-fast: false
matrix:
job:
# To sort the matrix, use inline syntax.
- { target-os: alpine, target: x86_64-unknown-linux-musl }
- { target-os: ubuntu, target: x86_64-unknown-linux-gnu }
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Log in to the Container registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Generates tags for alpine:
# latest
# alpine
# 0.1
# 0.1-alpine
# 0.1.3
# 0.1.3-alpine
#
# For ubuntu:
# ubuntu
# 0.1-ubuntu
# 0.1.3-ubuntu
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
suffix=-${{ matrix.job.target-os }},onlatest=true
tags: |
type=raw,value=latest,suffix=,enable=${{ matrix.job.target-os == 'alpine' }}
type=raw,value=${{ matrix.job.target-os }},suffix=
type=semver,pattern={{major}}.{{minor}},suffix=,enable=${{ matrix.job.target-os == 'alpine' }}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}},suffix=,enable=${{ matrix.job.target-os == 'alpine' }}
type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
file: Dockerfile-${{ matrix.job.target-os }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Extract binary from Docker image
run: |
image_name="$(echo ${{ env.IMAGE_NAME }} | tr [:upper:] [:lower:])"
container_id="$(docker create "${{ env.REGISTRY }}/${image_name}:latest-${{ matrix.job.target-os }}")"
docker cp "${container_id}:/usr/local/bin/orgu" ./orgu
docker rm "${container_id}"
- name: Archive extracted binary
run: |
tar --create --gzip --verbose --file=${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz ${{ needs.crate-metadata.outputs.name }}
- name: Calculate checksum
run: |
sha256sum ${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz > ${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz.sha256
- name: Upload release binary
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # v2.3.3
with:
draft: true # For immutable release.
files: |
${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz
${{ needs.crate-metadata.outputs.name }}-${{ matrix.job.target }}.tar.gz.sha256
publish-release:
name: Publish release
if: startsWith(github.ref, 'refs/tags/v')
timeout-minutes: 5
needs:
- build-release
- build-release-docker
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Publish draft release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release edit ${{ github.ref_name }} --draft=false