|
5 | 5 | - "Build and publish docker"
|
6 | 6 | types:
|
7 | 7 | - "completed"
|
| 8 | + branches: |
| 9 | + - main |
| 10 | + - develop |
| 11 | + pull_request: |
| 12 | + types: [closed] |
| 13 | + branches: |
| 14 | + - main |
8 | 15 |
|
9 | 16 | jobs:
|
10 | 17 | on-success:
|
11 | 18 | runs-on: ubuntu-latest
|
12 |
| - if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 19 | + if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }} || ${{ github.event_name == 'pull_request' }} |
13 | 20 | strategy:
|
14 | 21 | fail-fast: false
|
15 | 22 | matrix:
|
@@ -70,59 +77,72 @@ jobs:
|
70 | 77 |
|
71 | 78 | steps:
|
72 | 79 | - run: "echo 'The relese triggering workflows passed'"
|
| 80 | + |
73 | 81 | - name: "set env"
|
| 82 | + id: "set-env" |
74 | 83 | run: |
|
75 |
| - if [ ${{ matrix.platform }} = "linux/amd64" ];then PLATFORM_MAP="x86_64";else PLATFORM_MAP="aarch64";fi |
76 |
| - if [ ${{ github.ref_name == 'develop' }} ];then BUILD_NAME="rpxy-nightly";else BUILD_NAME="rpxy";fi |
77 |
| - echo "PLATFORM_MAP=${PLATFORM_MAP}" >> $GITHUB_ENV |
78 |
| - echo "TARGET_NAME=${BUILD_NAME}-${PLATFORM_MAP}-unknown-linux-${{ matrix.target }}${{ matrix.build-feature }}" >> $GITHUB_ENV |
| 84 | + if [ ${{ matrix.platform }} == 'linux/amd64' ]; then PLATFORM_MAP="x86_64"; else PLATFORM_MAP="aarch64"; fi |
| 85 | + if [ ${{ github.ref_name }} == 'develop' ]; then BUILD_NAME="-nightly"; else BUILD_NAME=""; fi |
| 86 | + if [ ${{ github.ref_name }} == 'develop' ]; then BUILD_IMG="nightly"; else BUILD_IMG="latest"; fi |
| 87 | + echo "build_img=${BUILD_IMG}" >> $GITHUB_OUTPUT |
| 88 | + echo "target_name=rpxy${BUILD_NAME}-${PLATFORM_MAP}-unknown-linux-${{ matrix.target }}${{ matrix.build-feature }}" >> $GITHUB_OUTPUT |
79 | 89 |
|
80 | 90 | - name: "docker pull and extract binary from docker image"
|
81 | 91 | id: "extract-binary"
|
82 | 92 | run: |
|
83 |
| - CONTAINER_ID=`docker create --platform=${{ matrix.platform }} ghcr.io/junkurihara/rust-rpxy:nightly${{ matrix.tags-suffix }}` |
84 |
| - docker cp ${CONTAINER_ID}:/rpxy/bin/rpxy /tmp/${TARGET_NAME} |
85 |
| - cd /tmp |
86 |
| - echo "artifact=${TARGET_NAME}" >> $GITHUB_OUTPUT |
| 93 | + CONTAINER_ID=`docker create --platform=${{ matrix.platform }} ghcr.io/junkurihara/rust-rpxy:${{ steps.set-env.outputs.build_img }}${{ matrix.tags-suffix }}` |
| 94 | + docker cp ${CONTAINER_ID}:/rpxy/bin/rpxy /tmp/${{ steps.set-env.outputs.target_name }} |
87 | 95 |
|
88 | 96 | - name: "upload artifacts"
|
89 | 97 | uses: actions/upload-artifact@v3
|
90 | 98 | with:
|
91 |
| - name: ${{ steps.extract-binary.outputs.artifact }} |
92 |
| - path: "/tmp/${{ steps.extract-binary.outputs.artifact }}" |
| 99 | + name: ${{ steps.set-env.outputs.target_name }} |
| 100 | + path: "/tmp/${{ steps.set-env.outputs.target_name }}" |
93 | 101 |
|
94 | 102 | on-failure:
|
95 | 103 | runs-on: ubuntu-latest
|
96 |
| - if: ${{ github.event.workflow_run.conclusion == 'failure' }} |
| 104 | + if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' }} |
97 | 105 | steps:
|
98 | 106 | - run: echo 'The release triggering workflows failed'
|
99 | 107 |
|
100 | 108 | release:
|
101 | 109 | runs-on: ubuntu-latest
|
102 |
| - if: startsWith(github.ref, 'refs/tags/') |
| 110 | + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }} |
103 | 111 | needs: on-success
|
104 | 112 | steps:
|
| 113 | + - name: check pull_request title |
| 114 | + uses: actions-ecosystem/action-regex-match@v2 |
| 115 | + id: regex-match |
| 116 | + with: |
| 117 | + text: ${{ github.event.pull_request.title }} |
| 118 | + regex: "^(\\d+\\.\\d+\\.\\d+)$" |
| 119 | + |
105 | 120 | - name: checkout
|
| 121 | + if: ${{ steps.regex-match.outputs.match != '' }} |
106 | 122 | uses: actions/checkout@v4
|
107 | 123 |
|
108 | 124 | - name: download artifacts
|
| 125 | + if: ${{ steps.regex-match.outputs.match != ''}} |
109 | 126 | uses: actions/download-artifact@v3
|
110 | 127 | with:
|
111 | 128 | path: /tmp/rpxy
|
112 | 129 |
|
113 | 130 | - name: make tar.gz of assets
|
| 131 | + if: ${{ steps.regex-match.outputs.match != ''}} |
114 | 132 | run: |
|
115 | 133 | mkdir /tmp/assets
|
116 | 134 | cd /tmp/rpxy
|
117 | 135 | for i in ./*; do sh -c "cd $i && tar zcvf $i.tar.gz $i && mv $i.tar.gz /tmp/assets/"; done
|
118 | 136 | ls -lha /tmp/assets
|
119 | 137 |
|
120 | 138 | - name: release
|
| 139 | + if: ${{ steps.regex-match.outputs.match != ''}} |
121 | 140 | uses: softprops/action-gh-release@v1
|
122 |
| - if: startsWith(github.ref, 'refs/tags/') |
123 | 141 | with:
|
124 | 142 | files: /tmp/assets/*.tar.gz
|
125 |
| - tag_name: ${{ github.ref }} |
| 143 | + name: ${{ github.event.pull_request.title }} |
| 144 | + tag_name: ${{ github.event.pull_request.title }} |
| 145 | + body: ${{ github.event.pull_request.body }} |
126 | 146 | draft: true
|
127 | 147 | prerelease: false
|
128 | 148 | generate_release_notes: true
|
0 commit comments