on:
push:
tags:
- 'v*'
name: Release
env:
RELEASE_BIN: git-mirror
RELEASE_ADDS: README.md LICENSE
jobs:
build:
name: Build release
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux, macos, windows]
include:
- build: linux
os: ubuntu-latest
rust: stable
release_suffix: linux-x86_64.tar.gz
- build: macos
os: macos-latest
rust: stable
release_suffix: mac-x86_64.zip
- build: windows
os: windows-latest
rust: stable
release_suffix: windows-x86_64.zip
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- name: Build release binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Inject enhanced GitHub environment variables
uses: rlespinasse/github-slug-action@v5
- name: Create artifact directory
run: mkdir artifacts
- name: Create archive for Linux
run: 7z a -ttar -so -an ./target/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }} | 7z a -si ./artifacts/${{ env.RELEASE_BIN }}-${{ env.GITHUB_REF_POINT_SLUG }}-${{ matrix.release_suffix }}
if: matrix.os == 'ubuntu-latest'
- name: Create archive for Windows
run: 7z a -tzip ./artifacts/${{ env.RELEASE_BIN }}-${{ env.GITHUB_REF_POINT_SLUG }}-${{ matrix.release_suffix }} ./target/release/${{ env.RELEASE_BIN }}.exe ${{ env.RELEASE_ADDS }}
if: matrix.os == 'windows-latest'
- name: Install p7zip
run: brew install p7zip
if: matrix.os == 'macos-latest'
- name: Create archive for MacOS
run: 7z a -tzip ./artifacts/${{ env.RELEASE_BIN }}-${{ env.GITHUB_REF_POINT_SLUG }}-${{ matrix.release_suffix }} ./target/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_ADDS }}
if: matrix.os == 'macos-latest'
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./artifacts/${{ env.RELEASE_BIN }}-${{ env.GITHUB_REF_POINT_SLUG }}-${{ matrix.release_suffix }}
asset_name: ${{ env.RELEASE_BIN }}-${{ env.GITHUB_REF_POINT_SLUG }}-${{ matrix.release_suffix }}
tag: ${{ github.ref }}
docker:
name: Build and push Docker image
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Inject enhanced GitHub environment variables
uses: rlespinasse/github-slug-action@v5
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- 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: .
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.GITHUB_REF_POINT_SLUG }}
ghcr.io/${{ github.repository }}:latest
labels: |
org.opencontainers.image.source=${{ github.repositoryUrl }}
org.opencontainers.image.revision=${{ github.sha }}