fix: fix release flow

This commit is contained in:
Jun Kurihara 2023-10-12 15:40:25 +09:00
commit a5a6840fbe
No known key found for this signature in database
GPG key ID: D992B3E3DE1DED23
2 changed files with 34 additions and 28 deletions

View file

@ -4,8 +4,8 @@ on:
branches: branches:
- "develop" - "develop"
- "main" - "main"
tags: pull_request:
- "*.*.*" types: [synchronize, opened]
env: env:
GHCR: ghcr.io GHCR: ghcr.io
@ -119,19 +119,19 @@ jobs:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
# - name: Nightly build test on amd64 for pull requests - name: Nightly build test on amd64 for pull requests
# if: ${{ github.event_name == 'pull_request' }} if: ${{ github.event_name == 'pull_request' }}
# uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
# with: with:
# context: . context: .
# build-args: ${{ matrix.build-args }} build-args: ${{ matrix.build-args }}
# push: false push: false
# build-contexts: ${{ matrix.build-contexts }} build-contexts: ${{ matrix.build-contexts }}
# file: ${{ matrix.dockerfile }} file: ${{ matrix.dockerfile }}
# cache-from: type=gha,scope=rpxy-nightly-${{ matrix.target }} cache-from: type=gha,scope=rpxy-nightly-${{ matrix.target }}
# cache-to: type=gha,mode=max,scope=rpxy-nightly-${{ matrix.target }} cache-to: type=gha,mode=max,scope=rpxy-nightly-${{ matrix.target }}
# platforms: linux/amd64 platforms: linux/amd64
# labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
- name: Nightly build and push from develop branch - name: Nightly build and push from develop branch
if: ${{ (github.ref_name == 'develop') && (github.event_name == 'push') }} if: ${{ (github.ref_name == 'develop') && (github.event_name == 'push') }}

View file

@ -5,6 +5,10 @@ on:
- "Build and publish docker" - "Build and publish docker"
types: types:
- "completed" - "completed"
pull_request:
types: [closed]
branches:
- main
jobs: jobs:
on-success: on-success:
@ -70,26 +74,27 @@ jobs:
steps: steps:
- run: "echo 'The relese triggering workflows passed'" - run: "echo 'The relese triggering workflows passed'"
- name: "set env" - name: "set env"
id: "set-env"
run: | run: |
if [ ${{ matrix.platform }} = "linux/amd64" ]; then PLATFORM_MAP="x86_64"; else PLATFORM_MAP="aarch64"; fi if [ ${{ matrix.platform }} = "linux/amd64" ]; then PLATFORM_MAP="x86_64"; else PLATFORM_MAP="aarch64"; fi
if [ ${{ github.ref_name == 'develop' }} ];then BUILD_NAME="rpxy-nightly";else BUILD_NAME="rpxy";fi if [ ${{ github.ref_name == 'develop' }} ]; then BUILD_NAME="-nightly"; else BUILD_NAME=""; fi
echo "PLATFORM_MAP=${PLATFORM_MAP}" >> $GITHUB_ENV if [ ${{ github.ref_name == 'develop' }} ]; then BUILD_IMG="nightly"; else BUILD_IMG="latest"; fi
echo "TARGET_NAME=${BUILD_NAME}-${PLATFORM_MAP}-unknown-linux-${{ matrix.target }}${{ matrix.build-feature }}" >> $GITHUB_ENV echo "build_img=${BUILD_IMG}" >> $GITHUB_OUTPUT
echo "target_name=rpxy${BUILD_NAME}-${PLATFORM_MAP}-unknown-linux-${{ matrix.target }}${{ matrix.build-feature }}" >> $GITHUB_OUTPUT
- name: "docker pull and extract binary from docker image" - name: "docker pull and extract binary from docker image"
id: "extract-binary" id: "extract-binary"
run: | run: |
CONTAINER_ID=`docker create --platform=${{ matrix.platform }} ghcr.io/junkurihara/rust-rpxy:nightly${{ matrix.tags-suffix }}` CONTAINER_ID=`docker create --platform=${{ matrix.platform }} ghcr.io/junkurihara/rust-rpxy:${{ steps.set-env.outputs.build_img }}${{ matrix.tags-suffix }}`
docker cp ${CONTAINER_ID}:/rpxy/bin/rpxy /tmp/${TARGET_NAME} docker cp ${CONTAINER_ID}:/rpxy/bin/rpxy /tmp/${{ steps.set-env.outputs.target_name }}
cd /tmp
echo "artifact=${TARGET_NAME}" >> $GITHUB_OUTPUT
- name: "upload artifacts" - name: "upload artifacts"
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: ${{ steps.extract-binary.outputs.artifact }} name: ${{ steps.set-env.outputs.target_name }}
path: "/tmp/${{ steps.extract-binary.outputs.artifact }}" path: "/tmp/${{ steps.set-env.outputs.target_name }}"
on-failure: on-failure:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -99,7 +104,7 @@ jobs:
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') if: ${{ github.event_name == 'pull_request' }}
needs: on-success needs: on-success
steps: steps:
- name: checkout - name: checkout
@ -119,10 +124,11 @@ jobs:
- name: release - name: release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with: with:
files: /tmp/assets/*.tar.gz files: /tmp/assets/*.tar.gz
tag_name: ${{ github.ref }} name: ${{ github.event.pull_request.title }}
tag_name: ${{ github.event.pull_request.title }}
body: ${{ github.event.pull_request.body }}
draft: true draft: true
prerelease: false prerelease: false
generate_release_notes: true generate_release_notes: true