Refactor standard.yml to add support for pushing Docker images to Ten… #52
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build_standard | |
on: | |
push: | |
branches: [ "**"] | |
pull_request: | |
branches: [ "master" ] | |
permissions: | |
contents: write | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
standard: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set outputs | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short=8 HEAD)" >> $GITHUB_OUTPUT | |
- name: build | |
id: build | |
uses: arloor/rust_musl_action@latest | |
with: | |
use_musl: false | |
extra_deps: cmake | |
args: -p rust_http_proxy --no-default-features --features aws_lc_rs | |
apt_mirror: mirrors.mit.edu | |
rust_flags: -C target-feature=+crt-static | |
- name: docker build and push | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
run: | | |
ls -lh ${{ steps.build.outputs.release_dir }} | |
dockerfile="Dockerfile.static" | |
podman build -f ${dockerfile} . -t docker.io/arloor/rust_http_proxy:latest -t ccr.ccs.tencentyun.com/arloor/rust_http_proxy:latest --build-arg TARGET_PATH=/x86_64-unknown-linux-gnu | |
podman login docker.io -u arloor -p ${{ secrets.REGISTRY_PASSWORD }} | |
# podman push docker.io/arloor/rust_http_proxy:${{ steps.vars.outputs.sha_short }} | |
podman push docker.io/arloor/rust_http_proxy:latest | |
docker login ccr.ccs.tencentyun.com --username=1293181335 -p ${{ secrets.CCR_REGISTRY_PASSWORD }} | |
podman push ccr.ccs.tencentyun.com/arloor/rust_http_proxy:latest | |
- name: create master release | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
version=latest | |
if $(gh release delete ${version} -y --cleanup-tag); | |
then echo "delete old release"; | |
else echo "no old release"; | |
fi | |
git config --local user.email "[email protected]" | |
git config --local user.name "arloor" | |
gh release create ${version} ${{ steps.build.outputs.release_dir }}rust_http_proxy -n "$version" --latest -t "$version" | |
- name: create version release | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/') | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
# 从Cargo.toml中提取版本号 | |
version=$(grep -E ^version rust_http_proxy/Cargo.toml|awk -F "[\"]" '{print $2}') | |
version="v${version}" | |
if [ -z "$version" ]; then echo "version not found"; exit 1; fi | |
if $(gh release delete ${version} -y --cleanup-tag); | |
then echo "delete old release"; | |
else echo "no old release"; | |
fi | |
git config --local user.email "[email protected]" | |
git config --local user.name "arloor" | |
gh release create ${version} ${{ steps.build.outputs.release_dir }}rust_http_proxy -n "$version" --latest -t "$version" |