From 1a06f5ba4887b77ef257b2dfb8ad3948ce4e2560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Thu, 3 Jun 2021 17:32:03 +0200 Subject: [PATCH] Only attempt a starcatcher upload if the relevant repo secrets are present Also get rid of the release_url hack. --- .github/get-release-info.sh | 2 -- .github/starcatcher-check.sh | 5 +++++ .github/workflows/build.yaml | 29 +++++++++++++---------------- 3 files changed, 18 insertions(+), 18 deletions(-) delete mode 100755 .github/get-release-info.sh create mode 100755 .github/starcatcher-check.sh diff --git a/.github/get-release-info.sh b/.github/get-release-info.sh deleted file mode 100755 index 1d6b66909..000000000 --- a/.github/get-release-info.sh +++ /dev/null @@ -1,2 +0,0 @@ -value=`cat release_url/release_url.txt` -echo ::set-output name=upload_url::$value diff --git a/.github/starcatcher-check.sh b/.github/starcatcher-check.sh new file mode 100755 index 000000000..1905c827f --- /dev/null +++ b/.github/starcatcher-check.sh @@ -0,0 +1,5 @@ +if [ ! -z "$STARCATCHER_PUBLISH_HOSTPORT" ]; then + echo ::set-output name=can_publish::yes +else + echo ::set-output name=can_publish::no +fi diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b6eba0a46..7698c2ffa 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,6 +14,9 @@ on: jobs: release: runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + can_publish: ${{ steps.starcatcher_check.outputs.can_publish }} steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 @@ -31,11 +34,11 @@ jobs: release_name: ${{ steps.get_type.outputs.NAME }} draft: true prerelease: false - - run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt - - uses: actions/upload-artifact@v1 - with: - name: release_url - path: release_url.txt + - id: starcatcher_check + if: steps.get_type.outputs.TYPE != 'dev' + run: bash -c './.github/starcatcher-check.sh' + env: + STARCATCHER_PUBLISH_HOSTPORT: ${{ secrets.STARCATCHER_PUBLISH_HOSTPORT }} build: runs-on: ${{ matrix.os }} needs: [release] @@ -91,12 +94,6 @@ jobs: python-version: '3.8' - id: get_type run: python3 ./.github/get-type.py ${{ github.ref }} - - uses: actions/download-artifact@v1 - with: - name: release_url - - id: get_release_info - if: steps.get_type.outputs.TYPE != 'dev' - run: bash -c "./.github/get-release-info.sh" ## gg github, this is terrible - if: matrix.platform_short == 'mac' uses: Homebrew/actions/setup-homebrew@master - if: matrix.platform_short == 'mac' @@ -120,7 +117,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.get_release_info.outputs.upload_url }} + upload_url: ${{ needs.release.outputs.upload_url }} asset_path: powder${{ matrix.suffix }} asset_name: powder-${{ steps.get_type.outputs.NAME }}-${{ matrix.machine_short }}-${{ matrix.platform_short }}-${{ matrix.toolset_short }}-${{ matrix.static_dynamic }}${{ matrix.suffix }} asset_content_type: application/zip @@ -131,8 +128,8 @@ jobs: name: powder-${{ steps.get_type.outputs.NAME }}-${{ matrix.machine_short }}-${{ matrix.platform_short }}-${{ matrix.toolset_short }}-${{ matrix.static_dynamic }}${{ matrix.suffix }} starcatcher-upload: runs-on: ubuntu-latest - needs: [build] - if: startsWith(github.ref, 'refs/tags/') # not a perfect match but get-type.py takes care of this in job build + needs: [build, release] + if: needs.release.outputs.can_publish == 'yes' && startsWith(github.ref, 'refs/tags/') # not a perfect match but get-type.py takes care of this in job build strategy: matrix: ######################################################### @@ -185,8 +182,8 @@ jobs: STARCATCHER_PUBLISH_FILENAME: powder-${{ steps.get_type.outputs.NAME }}-${{ matrix.machine_short }}-${{ matrix.platform_short }}-${{ matrix.toolset_short }}-${{ matrix.static_dynamic }}${{ matrix.suffix }} starcatcher-release: runs-on: ubuntu-latest - needs: [starcatcher-upload] - if: startsWith(github.ref, 'refs/tags/') # not a perfect match but get-type.py takes care of this in job build + needs: [starcatcher-upload, release] + if: needs.release.outputs.can_publish == 'yes' && startsWith(github.ref, 'refs/tags/') # not a perfect match but get-type.py takes care of this in job build steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2