Skip to content

release

release #19

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: |
cross build --release --target x86_64-unknown-linux-musl && mv ./target/x86_64-unknown-linux-musl/release/httpget httpget.x86_64 && cargo clean
cross build --release --target x86_64-unknown-linux-musl --features tls && mv ./target/x86_64-unknown-linux-musl/release/httpget httpget-tls.x86_64 && cargo clean
cross build --release --target aarch64-unknown-linux-musl && mv ./target/aarch64-unknown-linux-musl/release/httpget httpget.aarch64 && cargo clean
cross build --release --target aarch64-unknown-linux-musl --features tls && mv ./target/aarch64-unknown-linux-musl/release/httpget httpget-tls.aarch64 && cargo clean
cp ./httpget.x86_64 ./httpget
cp ./httpget-tls.x86_64 ./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@v3
with:
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
target: runner-tls
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@v3
with:
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
target: runner
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 }} \
httpget*
env:
GH_TOKEN: ${{ github.token }}