mirror of
https://github.com/samsonjs/agate.git
synced 2026-03-25 09:05:50 +00:00
This Github workflow builds & publishes an OCI/Docker container image to Github/s Container Registry (ghcr.io). It also adds a brief intro for how to use it in the README, and removes the (now outdated) `tools/docker/README.md`.
112 lines
3.9 KiB
YAML
112 lines
3.9 KiB
YAML
name: Release Builds
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*' # on every version tag
|
|
|
|
jobs:
|
|
# first just a small job to draft the release so all others can use the upload_url
|
|
create_release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: create release
|
|
id: create_release
|
|
uses: ncipollo/release-action@v1
|
|
|
|
build_ubuntu:
|
|
runs-on: ubuntu-20.04
|
|
needs: create_release
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: build
|
|
run: bash .github/workflows/release.sh
|
|
- name: upload release assets linux
|
|
uses: AButler/upload-release-assets@v3.0
|
|
with:
|
|
files: 'agate.*.gz'
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
release-tag: ${{ github.ref_name }}
|
|
|
|
build_windows:
|
|
runs-on: windows-latest
|
|
needs: create_release
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Build
|
|
run: cargo build --verbose --release
|
|
- name: strip names
|
|
run: strip target/release/agate.exe
|
|
- name: compress
|
|
run: Compress-Archive -LiteralPath target/release/agate.exe -DestinationPath agate.x86_64-pc-windows-msvc.zip
|
|
- name: upload release asset win
|
|
uses: AButler/upload-release-assets@v3.0
|
|
with:
|
|
files: agate.x86_64-pc-windows-msvc.zip
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
release-tag: ${{ github.ref_name }}
|
|
|
|
build_macos_x86_64:
|
|
runs-on: macos-latest
|
|
needs: create_release
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: install toolchain
|
|
run: rustup target add aarch64-apple-darwin
|
|
- name: Build x86_64
|
|
run: cargo build --verbose --release
|
|
- name: strip names x86
|
|
run: strip target/release/agate
|
|
- name: compress x86
|
|
run: gzip -c target/release/agate > ./agate.x86_64-apple-darwin.gz
|
|
- name: Build ARM
|
|
run: SDKROOT=$(xcrun -sdk macosx --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version) cargo build --verbose --release --target=aarch64-apple-darwin
|
|
- name: strip names ARM
|
|
run: strip target/aarch64-apple-darwin/release/agate
|
|
- name: compress ARM
|
|
run: gzip -c target/aarch64-apple-darwin/release/agate > ./agate.aarch64-apple-darwin.gz
|
|
- name: upload release assets darwin
|
|
uses: AButler/upload-release-assets@v3.0
|
|
with:
|
|
files: 'agate.*.gz'
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
release-tag: ${{ github.ref_name }}
|
|
|
|
build_docker:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Log into GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Extract metadata for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ghcr.io/${{ github.repository }}
|
|
# Because this workflow only runs on commits tagged `v*` (i n semver format) this section ensures that
|
|
# a docker build tagged `v1.2.3+podman.build` is tagged with `1`, `1.2`, `1.2.3` and `1.2.3+podman.build`
|
|
# as well as being tagged with `latest`. For each of these, a subsequent build that has the same tag will
|
|
# replace it. This means that pulling `ghcr.io/mbrubeck/agate:1` will always get the most recent image
|
|
# released with a v1 tag, container, `ghcr.io/mbrubeck/agate:1.2` will get the latest v1.2 tag, and so on.
|
|
tags: |
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}.{{patch}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}}
|
|
- name: Build and push Docker image
|
|
id: push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|