Skip to content

Commit

Permalink
Refactor CI workflow to build, publish Docker image, and release bina…
Browse files Browse the repository at this point in the history
…ries
  • Loading branch information
Aitthi committed Sep 29, 2024
1 parent fe5a63a commit e99e236
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
40 changes: 23 additions & 17 deletions .github/workflows/Ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- release

jobs:
build-docker-image:
build-and-push-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -20,33 +20,39 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and Push Docker image
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo $DOCKER_PASSWORD | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/assetsart/easy-proxy:${{ github.sha }} . --push
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull and tag latest Docker image
run: |
docker pull ghcr.io/assetsart/easy-proxy:${{ github.sha }}
docker tag ghcr.io/assetsart/easy-proxy:${{ github.sha }} ghcr.io/assetsart/easy-proxy:latest
docker push ghcr.io/assetsart/easy-proxy:latest
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/assetsart/easy-proxy:${{ github.sha }},ghcr.io/assetsart/easy-proxy:latest

build-and-release-binaries:
runs-on: ubuntu-latest
needs: build-docker-image
needs: build-and-push-docker-image
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential pkg-config libssl-dev perl
- name: Set up Rust
uses: actions/setup-rust@v1
with:
rust-version: stable

- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
run: cargo install cross

- name: Build Linux binary
run: |
Expand All @@ -60,7 +66,7 @@ jobs:
mkdir -p build/macos
cp target/x86_64-apple-darwin/release/easy-proxy build/macos/
- name: Create Release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
Expand All @@ -71,7 +77,7 @@ jobs:
draft: false
prerelease: false

- name: Upload Linux binary to Release
- name: Upload Linux Binary to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -81,7 +87,7 @@ jobs:
asset_name: easy-proxy-linux
asset_content_type: application/octet-stream

- name: Upload macOS binary to Release
- name: Upload macOS Binary to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ RUN set -eux; \
cmake \
libssl-dev \
make \
pkg-config
pkg-config \
perl

WORKDIR /app
# copy app src
Expand Down

0 comments on commit e99e236

Please sign in to comment.