مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
chore(build): improve build process, add release please (#2414)
هذا الالتزام موجود في:
146
.github/workflows/ci.yml
مباع
146
.github/workflows/ci.yml
مباع
@@ -3,63 +3,111 @@ name: CI
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
# lint:
|
||||
# name: Lint
|
||||
# runs-on: self-hosted
|
||||
# steps:
|
||||
# - uses: actions/checkout@v3
|
||||
# - run: make ci-lint
|
||||
release-please:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main'
|
||||
outputs:
|
||||
release_created: ${{ steps.release-please.outputs.release_created }}
|
||||
tag_name: ${{ steps.release-please.outputs.tag_name }} # e.g. v1.0.0
|
||||
version: ${{ steps.release-please.outputs.version }} # e.g. 1.0.0
|
||||
all: ${{ toJSON(steps.release-please.outputs) }}
|
||||
steps:
|
||||
- uses: google-github-actions/release-please-action@v3
|
||||
id: release-please
|
||||
with:
|
||||
command: manifest
|
||||
|
||||
build:
|
||||
name: CI Image Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
- uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: ghcr.io/postalserver/postal:ci-${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
target: ci
|
||||
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run tests
|
||||
run: make ci-test
|
||||
|
||||
build-latest:
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [test]
|
||||
if: github.ref == 'refs/heads/main'
|
||||
name: Test Suite
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Parse git ref
|
||||
run: |
|
||||
echo "DOCKER_TAG_NAME=$(basename $GITHUB_REF)" >> $GITHUB_ENV
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
||||
- uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: make docker-release
|
||||
|
||||
build-release:
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [test]
|
||||
if: contains(github.ref, 'refs/tags/')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Parse git ref
|
||||
run: |
|
||||
echo "DOCKER_TAG_NAME=$(basename $GITHUB_REF)" >> $GITHUB_ENV
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: make docker-release
|
||||
- run: docker-compose pull
|
||||
env:
|
||||
DOCKER_TAG_NAME: "latest"
|
||||
POSTAL_IMAGE: ghcr.io/postalserver/postal:ci-${{ github.sha }}
|
||||
- run: docker-compose run postal sh -c 'bundle exec rspec'
|
||||
env:
|
||||
POSTAL_IMAGE: ghcr.io/postalserver/postal:ci-${{ github.sha }}
|
||||
|
||||
release-branch:
|
||||
name: Release (branch)
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build]
|
||||
if: startsWith(github.ref, 'refs/heads/')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
- uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- id: tag
|
||||
run: |
|
||||
TAG="${GITHUB_REF#refs/heads/}"
|
||||
if [ -z "$TAG" ]; then exit 1; fi
|
||||
if [[ $TAG == "main" ]]; then TAG="latest"; else TAG="branch-${TAG}"; fi
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
- uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/postalserver/postal:${{ steps.tag.outputs.tag }}
|
||||
ghcr.io/postalserver/postal:commit-${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
target: full
|
||||
|
||||
publish-image:
|
||||
name: Publish Image
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, test, release-please]
|
||||
if: ${{ needs.release-please.outputs.release_created }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
- uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ vars.KRYSTAL_REGISTRY_HOST }}
|
||||
username: ${{ vars.KRYSTAL_REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.KRYSTAL_REGISTRY_PASSWORD }}
|
||||
- uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/postalserver/postal:stable
|
||||
ghcr.io/postalserver/postal:${{ needs.release-please.outputs.version }}
|
||||
cache-from: type=local,src=/cache/krystal-identity
|
||||
cache-to: type=local,dest=/cache/krystal-identity,mode=max
|
||||
target: full
|
||||
build-args: |
|
||||
VERSION=${{ needs.release-please.outputs.version }}
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم