v0.8.1 #109
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
name: Release & Ship | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
branches: | |
- master | |
# Do not run the workflow if the project hasn't changed. | |
# NOTE: It will run on every tag push, but only if the `paths` filter is satisfied on the chosen `branches` | |
# (source: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore). | |
paths: | |
# We changed the code: | |
- "crates/*/src/**" | |
- "crates/*/src/Cargo.toml" | |
- "Cargo.toml" | |
- "Cargo.lock" | |
# We changed how the image is built: | |
- "Dockerfile" | |
- ".dockerignore" | |
# We changed how the workflow is ran: | |
- ".github/workflows/release.yaml" | |
# We changed some packaged documentation: | |
- "crates/*/static/**" | |
jobs: | |
create-github-release: | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Get current tag | |
id: current_tag | |
uses: WyriHaximus/github-action-get-previous-tag@v1 | |
- name: Release new version | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: ${{ steps.current_tag.outputs.tag }} | |
body: "⚠️ Changelog not yet provided." | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ship-docker-image: | |
environment: build-ship | |
runs-on: ubuntu-22.04 | |
permissions: | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Acquire Docker image metadata | |
id: metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ vars.DOCKERHUB_ORGANIZATION }}/prose-pod-api | |
ghcr.io/${{ github.repository }} | |
# NOTE: `latest` tag automatically handled (see https://github.com/docker/metadata-action?tab=readme-ov-file#latest-tag). | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=edge | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Log in to the 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: | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
push: true | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=max | |
build-args: | | |
CARGO_PROFILE=${{ startsWith(github.ref, 'refs/tags/') && 'release' || 'staging' }} | |
VERSION=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.version'] }} | |
COMMIT=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.revision'] }} | |
BUILD_TIMESTAMP=${{ fromJSON(steps.metadata.outputs.json).labels['org.opencontainers.image.created'] }} | |
CARGO_INSTALL_EXTRA_ARGS=--locked |