171 lines
5.1 KiB
YAML
171 lines
5.1 KiB
YAML
name: Release CI
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v[0-9]+.[0-9]+.[0-9]+"
|
|
|
|
jobs:
|
|
#################################################
|
|
## Cross platform binary build for release page #
|
|
#################################################
|
|
|
|
cross_platform_build:
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- target: x86_64-unknown-linux-musl
|
|
output_name: linux_x86_64.tar.gz
|
|
|
|
- target: aarch64-unknown-linux-musl
|
|
output_name: linux_aarch64.tar.gz
|
|
|
|
- target: arm-unknown-linux-musleabihf
|
|
output_name: linux_armv6.tar.gz
|
|
|
|
- target: aarch64-apple-darwin
|
|
output_name: apple_darwin_aarch64.tar.gz
|
|
|
|
- target: x86_64-pc-windows-gnu
|
|
output_name: windows_x86_64.zip
|
|
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
# Install stable rust, and associated tools
|
|
- name: install rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
# Install cross-rs
|
|
- name: install cross
|
|
run: cargo install cross --git https://github.com/cross-rs/cross
|
|
|
|
# Build binary for arm MacOS using Docker Zigbuild
|
|
- name: build
|
|
if: matrix.target == 'aarch64-apple-darwin'
|
|
run: |
|
|
docker run --rm -v $(pwd):/io -w /io ghcr.io/rust-cross/cargo-zigbuild cargo zigbuild --release --target aarch64-apple-darwin
|
|
|
|
# Build all other targets using Cross
|
|
- name: build
|
|
if: matrix.target != 'aarch64-apple-darwin'
|
|
run: cross build --target ${{ matrix.target }} --release
|
|
|
|
# Compress the output
|
|
- name: compress windows
|
|
if: matrix.target == 'x86_64-pc-windows-gnu'
|
|
run: |
|
|
zip -j "./oxker_${{ matrix.output_name }}" target/${{ matrix.target }}/release/oxker.exe
|
|
|
|
# Compress the output
|
|
- name: compress linux
|
|
if: matrix.target != 'x86_64-pc-windows-gnu'
|
|
run: |
|
|
tar -C "target/${{ matrix.target }}/release" -czf "./oxker_${{ matrix.output_name }}" oxker
|
|
|
|
# Upload output for release page
|
|
- name: Upload Artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
if-no-files-found: error
|
|
name: ${{ matrix.target }}
|
|
path: oxker_${{ matrix.output_name }}
|
|
retention-days: 1
|
|
|
|
###################
|
|
## Create release #
|
|
###################
|
|
|
|
create_release:
|
|
needs: [cross_platform_build]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup | Artifacts
|
|
uses: actions/download-artifact@v5
|
|
|
|
- name: Update Release
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
makeLatest: true
|
|
name: ${{ github.ref_name }}
|
|
tag: ${{ github.ref }}
|
|
bodyFile: ".github/release-body.md"
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
artifacts: |
|
|
**/oxker_*.zip
|
|
**/oxker_*.tar.gz
|
|
#########################################
|
|
## Build images for Dockerhub & ghcr.io #
|
|
#########################################
|
|
|
|
container_image_build:
|
|
needs: [create_release]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./containerised/Dockerfile
|
|
push: true
|
|
tags: |
|
|
${{ secrets.DOCKERHUB_USERNAME }}/{{ github.event.repository.name }}:latest
|
|
${{ secrets.DOCKERHUB_USERNAME }}/{{ github.event.repository.name }}:${{env.CURRENT_SEMVER}}
|
|
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
|
|
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.CURRENT_SEMVER }}
|
|
platforms: linux/arm/v6,linux/arm64,linux/amd64
|
|
provenance: false
|
|
sbom: false
|
|
|
|
########################
|
|
# Publish to crates.io #
|
|
########################
|
|
|
|
# This could be moved to before a github release is made
|
|
dry_run_cargo_publish:
|
|
runs-on: ubuntu-latest
|
|
needs: [container_image_build]
|
|
steps:
|
|
- name: update rust stable
|
|
run: rustup update stable
|
|
- uses: actions/checkout@v5
|
|
- name: Publish Dry Run
|
|
run: cargo publish --dry-run
|
|
|
|
cargo_publish:
|
|
environment: crates.io
|
|
runs-on: ubuntu-latest
|
|
needs: [dry_run_cargo_publish]
|
|
env:
|
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
|
|
steps:
|
|
- name: update rust stable
|
|
run: rustup update stable
|
|
- uses: actions/checkout@v5
|
|
- name: Publish
|
|
run: cargo publish
|
|
|