Skip to content

Commit

Permalink
Merge pull request #53 from AssetsArt/release
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
Aitthi authored Sep 29, 2024
2 parents 24cf80e + e5eba68 commit 8f1ec65
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 67 deletions.
105 changes: 39 additions & 66 deletions .github/workflows/Ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,87 +6,60 @@ on:
- release

jobs:
build-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all

- 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: 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
build-and-release-binaries:
permissions: write-all
runs-on: ubuntu-latest
needs: build-docker-image
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Rust
uses: actions/setup-rust@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rust-version: stable
toolchain: stable

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

- name: Build Linux binary
run: |
cross build --target x86_64-unknown-linux-gnu --release
mkdir -p build/linux
cp target/x86_64-unknown-linux-gnu/release/easy-proxy build/linux/
- name: Install jq
run: sudo apt-get install -y jq

- name: Build macOS binary
- name: Extract version from Cargo.toml
id: extract_version
run: |
cross build --target x86_64-apple-darwin --release
mkdir -p build/macos
cp target/x86_64-apple-darwin/release/easy-proxy build/macos/
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.sha }}
release_name: "Release ${{ github.sha }}"
draft: false
prerelease: false
# - name: Build Linux binary x86_64-gnu
# run: |
# cross build --target x86_64-unknown-linux-gnu --release
# mkdir -p build/linux-gnu/
# cp target/x86_64-unknown-linux-gnu/release/easy-proxy build/linux-gnu/

- name: Upload Linux binary to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/linux/easy-proxy
asset_name: easy-proxy-linux
asset_content_type: application/octet-stream
# - name: Build Linux binary x86_64-musl
# run: |
# cross build --target x86_64-unknown-linux-musl --release
# mkdir -p build/linux-musl/
# cp target/x86_64-unknown-linux-musl/release/easy-proxy build/linux-musl/

- name: Build Linux binary aarch64-gnu
run: |
cross build --target aarch64-unknown-linux-gnu --release
mkdir -p build/linux/
cp target/aarch64-unknown-linux-gnu/release/easy-proxy build/linux/aarch64-easy-proxy-linux-gnu
# - name: Build Linux binary aarch64-musl
# run: |
# cross build --target aarch64-unknown-linux-musl --release
# mkdir -p build/linux-musl/
# cp target/aarch64-unknown-linux-musl/release/easy-proxy build/linux-musl/

- name: Upload macOS binary to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push binaries to release
uses: softprops/action-gh-release@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/macos/easy-proxy
asset_name: easy-proxy-macos
asset_content_type: application/octet-stream
repository: ${{ github.repository }}
files: |
build/linux/aarch64-easy-proxy-linux-gnu
tag_name: v${{ steps.extract_version.outputs.version }}
name: v${{ steps.extract_version.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
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 8f1ec65

Please sign in to comment.