Skip to content

release

release #22

Workflow file for this run

name: release
on:
workflow_dispatch:
env:
VERSION: "0.1.${{ github.run_number }}"
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-test:
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install rust tool chain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy
target: x86_64-unknown-linux-musl
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install cross
run: cargo binstall -y cross
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install required tools
run: sudo apt update && sudo apt install musl-tools -y
- name: Lint the code
run: cargo clippy
- name: Run the security audit check
run: cargo audit
- name: Set the crate version
run: cargo install cargo-edit --bin cargo-set-version && cargo set-version ${{ env.VERSION }}
- name: Run the tests with the static target for the debug build
run: cross test --target x86_64-unknown-linux-musl && cargo clean
- name: Build the final binaries
run: |
mkdir -p ./bin
cross build --target x86_64-unknown-linux-musl --release && mv ./target/x86_64-unknown-linux-musl/release/httpget ./bin/httpget.x86_64
cargo clean
cross build --target x86_64-unknown-linux-musl --features tls --release && mv ./target/x86_64-unknown-linux-musl/release/httpget ./bin/httpget-tls.x86_64
cargo clean
cross build --target aarch64-unknown-linux-musl --release && mv ./target/aarch64-unknown-linux-musl/release/httpget ./bin/httpget.aarch64
cargo clean
cross build --target aarch64-unknown-linux-musl --features tls --release && mv ./target/aarch64-unknown-linux-musl/release/httpget ./bin/httpget-tls.aarch64
cp ./bin/httpget.x86_64 ./bin/httpget
cp ./bin/httpget-tls.x86_64 ./bin/httpget-tls
- name: List the files
run: ls -la
- name: Publish the crate
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Push the musl tls container
uses: docker/build-push-action@v4
with:
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
target: runner-tls
context: ./bin
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-tls,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-tls
- name: Push the musl runner container
uses: docker/build-push-action@v4
with:
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
target: runner
context: ./bin
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
- name: Publish the final binary as a release
run: |
gh release create --latest \
-n "Latest version of httpget, compiled for target x86_64-unknown-linux-musl and aarch64-unknown-linux-musl" \
-t "HttpGet v${{ env.VERSION}}" \
${{ env.VERSION }} \
./bin/httpget*
env:
GH_TOKEN: ${{ github.token }}