-
-
Notifications
You must be signed in to change notification settings - Fork 3
92 lines (78 loc) · 2.87 KB
/
Ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Build, Publish Docker Image, and Release Binaries
on:
push:
branches:
- 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:
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
with:
rust-version: 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: Build macOS binary
run: |
cross build --target x86_64-apple-darwin --release
mkdir -p build/macos
cp target/x86_64-apple-darwin/release/easy-proxy build/macos/
- 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: 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: Upload macOS 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/macos/easy-proxy
asset_name: easy-proxy-macos
asset_content_type: application/octet-stream