Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,38 @@ on:
- release-*
# tags:
# - v*
release:
types: [published]

workflow_dispatch:
inputs:
tag:
description: "Tag version to be used for Docker image"
required: true
default: "v3.8.0"
workflow_call:
inputs:
tag:
description: "Tag version to be used for Docker image"
required: true
type: string
checkout_sha:
description: "Commit SHA to checkout"
required: true
type: string
checkout_short_sha:
description: "Short commit SHA for image tags"
required: true
type: string

jobs:
build-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ inputs.checkout_sha || inputs.tag || github.event.inputs.tag }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
Expand Down Expand Up @@ -63,8 +79,10 @@ jobs:
# type=semver,pattern={{version}}
type=semver,pattern=v{{version}}
type=semver,pattern=release-{{raw}}
type=sha
type=raw,value=${{ github.event.inputs.tag }}
type=sha,enable=${{ inputs.checkout_short_sha == '' }}
type=raw,value=sha-${{ inputs.checkout_short_sha }},enable=${{ inputs.checkout_short_sha != '' }}
type=raw,value=${{ inputs.tag || github.event.inputs.tag }}
type=raw,value=latest,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}

- name: Build and push Docker image
uses: docker/build-push-action@v7
Expand All @@ -79,7 +97,8 @@ jobs:
run: |
images=("openim/openim-chat" "ghcr.io/openimsdk/openim-chat" "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat")
for image in "${images[@]}"; do
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n'); do
for ref in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n'); do
tag="${ref##*:}"
manifest=$(docker manifest inspect "$image:$tag" || echo "error")
if [[ "$manifest" == "error" ]]; then
echo "Manifest not found for $image:$tag"
Expand Down
52 changes: 47 additions & 5 deletions .github/workflows/docker-build-and-release-services-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,61 @@ on:
push:
branches:
- release-*
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Tag version to be used for Docker image"
required: true
default: "v3.8.3"
workflow_call:
inputs:
tag:
description: "Tag version to be used for Docker image"
required: true
type: string
checkout_sha:
description: "Commit SHA to checkout"
required: true
type: string
checkout_short_sha:
description: "Short commit SHA for image tags"
required: true
type: string

jobs:
services:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.services.outputs.services }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ inputs.checkout_sha || inputs.tag || github.event.inputs.tag }}

- name: Resolve service matrix
id: services
run: |
set -euo pipefail
services=$(docker compose -f build/images/openim-chat/docker-compose.build.yml config --services | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "services=$services" >> "$GITHUB_OUTPUT"

build-and-push:
needs: services
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
service: ${{ fromJson(needs.services.outputs.services) }}
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: ${{ inputs.checkout_sha || inputs.tag || github.event.inputs.tag }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
Expand Down Expand Up @@ -54,16 +93,19 @@ jobs:
type=ref,event=branch
type=semver,pattern=v{{version}}
type=semver,pattern=release-{{raw}}
type=sha
type=raw,value=${{ github.event.inputs.tag }}
type=sha,enable=${{ inputs.checkout_short_sha == '' }}
type=raw,value=sha-${{ inputs.checkout_short_sha }},enable=${{ inputs.checkout_short_sha != '' }}
type=raw,value=${{ inputs.tag || github.event.inputs.tag }}
type=raw,value=latest,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}

- name: Build and push Docker images
env:
PUSH: "true"
RELEASE: "true"
SERVICE: ${{ matrix.service }}
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
IMAGE_REGISTRIES: |
${{ secrets.DOCKER_USERNAME }}
ghcr.io/${{ github.repository_owner }}
registry.cn-hangzhou.aliyuncs.com/openimsdk
run: build/build.sh
run: build/build_single.sh
139 changes: 48 additions & 91 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1,56 @@
name: OpenIM chat release
name: Release

on:
push:
# run only against tags
tags:
- '*'
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Existing tag to release"
required: true
target_branch:
description: "Branch that the release tag was created from"
required: true

permissions:
actions: write
contents: write
packages: write
issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: setup-snapcraft
# FIXME: the mkdirs are a hack for https://github.com/goreleaser/goreleaser/issues/1715
run: |
sudo apt-get update
sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft
mkdir -p $HOME/.cache/snapcraft/download
mkdir -p $HOME/.cache/snapcraft/stage-packages

- uses: actions/setup-go@v6
with:
go-version: stable

- name: Set up QEMU
uses: docker/setup-qemu-action@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
concurrency:
group: release-${{ github.event.release.tag_name || inputs.tag }}
cancel-in-progress: false

- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to AliYun Docker Hub
uses: docker/login-action@v4
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALIREGISTRY_USERNAME }}
password: ${{ secrets.ALIREGISTRY_TOKEN }}

- name: set action env cache
uses: actions/cache@v4
with:
path: |
./_output/dist/*.deb
./_output/dist/*.rpm
./_output/dist/*.apk
key: ${{ github.ref }}

- uses: sigstore/cosign-installer@v4
- uses: anchore/sbom-action/download-syft@v0.24.0
- uses: crazy-max/ghaction-upx@v4
with:
install-only: true
- uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
# - name: snapcraft-login
# if: startsWith(github.ref, 'refs/tags/v')
# run: snapcraft login --with <(echo "${{ secrets.SNAPCRAFT_TOKEN }}")
# More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs.

- uses: goreleaser/goreleaser-action@v7
with:
# either 'goreleaser' (default) or 'goreleaser-pro':
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
USERNAME: ${{ github.repository_owner }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
# distribution:
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}

jobs:
update-version:
permissions:
contents: write
uses: ./.github/workflows/update-version-file-on-release.yml
with:
tag: ${{ github.event.release.tag_name || inputs.tag }}
target_branch: ${{ github.event.release.target_commitish || inputs.target_branch }}
secrets: inherit

docker-image:
needs: update-version
permissions:
contents: read
packages: write
uses: ./.github/workflows/build-docker-image.yml
with:
tag: ${{ github.event.release.tag_name || inputs.tag }}
checkout_sha: ${{ needs.update-version.outputs.updated_sha }}
checkout_short_sha: ${{ needs.update-version.outputs.updated_short_sha }}
secrets: inherit

service-images:
needs: update-version
permissions:
contents: read
packages: write
uses: ./.github/workflows/docker-build-and-release-services-images.yml
with:
tag: ${{ github.event.release.tag_name || inputs.tag }}
checkout_sha: ${{ needs.update-version.outputs.updated_sha }}
checkout_short_sha: ${{ needs.update-version.outputs.updated_short_sha }}
secrets: inherit
Loading
Loading