fix(deps): Docker (#63) #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
# Pattern matched against refs/tags | |
tags: | |
- '*' # Push events to every tag not containing / | |
workflow_dispatch: | |
inputs: | |
version: | |
description: Setup RELEASE_VERSION | |
required: true | |
type: string | |
name: Publish | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
check-versions: | |
name: Check all versions match | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install bump2version | |
run: pip install bump2version | |
- name: Set env | |
if: github.event_name != 'workflow_dispatch' | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Manually set env | |
if: ${{ inputs.version }} | |
run: echo "RELEASE_VERSION=${{ inputs.version }}" >> $GITHUB_ENV | |
- name: Compare versions | |
run: bump2version patch --dry-run --current-version=${{ env.RELEASE_VERSION }} --new-version=0.0.0 | |
publish-crate: | |
name: Publish binaries on crate.io | |
runs-on: ubuntu-latest | |
needs: check-versions | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- run: cargo publish --token ${CRATES_TOKEN} || echo "This never fails" | |
env: | |
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} | |
publish-docker: | |
name: Publish Docker image | |
runs-on: ubuntu-latest | |
needs: check-versions | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |