From e6b46cd5baf04256619efc93d10e86f6e08ad48b Mon Sep 17 00:00:00 2001 From: Mathieu Guay-Paquet Date: Wed, 8 Nov 2023 14:47:13 -0500 Subject: [PATCH 1/8] Upgrade actions/upload-artifact According to these changelogs: https://github.com/actions/upload-artifact/releases/tag/v3.0.0 https://github.com/actions/upload-artifact/releases/tag/v3.1.1 This should address the Github Actions warnings about upgrading from node12 to node16, and about not using `set-output`. --- .github/workflows/package-binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package-binaries.yml b/.github/workflows/package-binaries.yml index 894c1eb..498b8d1 100644 --- a/.github/workflows/package-binaries.yml +++ b/.github/workflows/package-binaries.yml @@ -129,7 +129,7 @@ jobs: tar -zcvf spinalcordtoolbox-binaries_${{ matrix.os }}.tar.gz -C pkg ./ - name: upload result - uses: actions/upload-artifact@v2-preview + uses: actions/upload-artifact@v3 with: name: spinalcordtoolbox-binaries_${{ matrix.os }} path: spinalcordtoolbox-binaries_${{ matrix.os }}.tar.gz From 563adcb2f3e66df92a4b233e07589d1e93dec920 Mon Sep 17 00:00:00 2001 From: Mathieu Guay-Paquet Date: Wed, 8 Nov 2023 15:17:57 -0500 Subject: [PATCH 2/8] Don't make files world-writable --- .github/workflows/package-binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package-binaries.yml b/.github/workflows/package-binaries.yml index 498b8d1..c26bf84 100644 --- a/.github/workflows/package-binaries.yml +++ b/.github/workflows/package-binaries.yml @@ -114,7 +114,7 @@ jobs: esac cp -p ctrDetect/LICENSE.txt pkg/copyright/LICENSE_ctrDetect.txt cp -p ctrDetect/LICENSE_opencv.txt pkg/copyright/ - chmod 666 pkg/copyright/* # upstream accidentally marked the licenses as programs, oops. + chmod -x pkg/copyright/* # upstream accidentally marked the licenses as programs, oops. - name: "'isct_' prefix" run: | From 8cd41317cd325a2373c67713f5ac6d575c3ace50 Mon Sep 17 00:00:00 2001 From: Mathieu Guay-Paquet Date: Wed, 8 Nov 2023 15:22:45 -0500 Subject: [PATCH 3/8] Upgrade actions/download-artifact This involves a change of behavior: https://github.com/actions/download-artifact#compatibility-between-v1-and-v2v3 Namely, artifacts are now downloaded to the current directory by default, instead of creating a (redundant, in our case) directory with the artifact name. --- .github/workflows/package-binaries.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/package-binaries.yml b/.github/workflows/package-binaries.yml index c26bf84..af785a6 100644 --- a/.github/workflows/package-binaries.yml +++ b/.github/workflows/package-binaries.yml @@ -152,15 +152,15 @@ jobs: draft: false prerelease: true - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v3 with: name: spinalcordtoolbox-binaries_linux - - - uses: actions/download-artifact@v1 + + - uses: actions/download-artifact@v3 with: name: spinalcordtoolbox-binaries_osx - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v3 with: name: spinalcordtoolbox-binaries_windows @@ -170,17 +170,17 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./spinalcordtoolbox-binaries_linux/spinalcordtoolbox-binaries_linux.tar.gz + asset_path: ./spinalcordtoolbox-binaries_linux.tar.gz asset_name: spinalcordtoolbox-binaries_linux.tar.gz asset_content_type: application/gzip - + - name: Upload Release Asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./spinalcordtoolbox-binaries_osx/spinalcordtoolbox-binaries_osx.tar.gz + asset_path: ./spinalcordtoolbox-binaries_osx.tar.gz asset_name: spinalcordtoolbox-binaries_osx.tar.gz asset_content_type: application/gzip @@ -190,6 +190,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./spinalcordtoolbox-binaries_windows/spinalcordtoolbox-binaries_windows.tar.gz + asset_path: ./spinalcordtoolbox-binaries_windows.tar.gz asset_name: spinalcordtoolbox-binaries_windows.tar.gz asset_content_type: application/gzip From 11eb40dae74928dd9a29010db426104440e20f33 Mon Sep 17 00:00:00 2001 From: Mathieu Guay-Paquet Date: Wed, 8 Nov 2023 15:27:24 -0500 Subject: [PATCH 4/8] Remove trailing whitespace --- .github/workflows/package-binaries.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/package-binaries.yml b/.github/workflows/package-binaries.yml index af785a6..ab24b9b 100644 --- a/.github/workflows/package-binaries.yml +++ b/.github/workflows/package-binaries.yml @@ -5,7 +5,7 @@ on: branches: [ master ] pull_request: branches: [ master ] - + # all this does is collect three dependencies, # - spinalcordtoolbox-ants which essentially a more minimal fork of https://github.com/ANTsX/ANTs # - spinalcordtoolbox-dev, which comes from https://github.com/neuropoly/spinalcordtoolbox/blob/master/dev @@ -42,8 +42,8 @@ jobs: mkdir -p pkg && cp -rp spinalcordtoolbox-ants/sct-apps/* pkg/ mkdir -p pkg/copyright mv pkg/COPYING.txt pkg/copyright/LICENSE_ANTs.txt - - + + # upstream: hhttps://github.com/biomedia-mira/stitching - name: get stitching run: | @@ -115,19 +115,19 @@ jobs: cp -p ctrDetect/LICENSE.txt pkg/copyright/LICENSE_ctrDetect.txt cp -p ctrDetect/LICENSE_opencv.txt pkg/copyright/ chmod -x pkg/copyright/* # upstream accidentally marked the licenses as programs, oops. - + - name: "'isct_' prefix" run: | # TODO: there's gotta be a shorter way to do this # add the isct_ to programs that don't already have it cd pkg find ./ -type f -executable ! -name "isct_*" -maxdepth 1 | while read fname; do mv "$fname" $(dirname "$fname")/isct_$(basename "$fname"); done - + - name: package run: | # Github Artifacts only make .zips, so make a .tar.gz manually to preserve permissions/dates/etc tar -zcvf spinalcordtoolbox-binaries_${{ matrix.os }}.tar.gz -C pkg ./ - + - name: upload result uses: actions/upload-artifact@v3 with: @@ -138,7 +138,7 @@ jobs: needs: [build] runs-on: ubuntu-latest #if: github.event_name == 'push' && github.branch_name == 'master' # only do a release on master - steps: + steps: - name: Create Release id: create_release uses: actions/create-release@v1 @@ -169,7 +169,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps asset_path: ./spinalcordtoolbox-binaries_linux.tar.gz asset_name: spinalcordtoolbox-binaries_linux.tar.gz asset_content_type: application/gzip @@ -179,7 +179,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps asset_path: ./spinalcordtoolbox-binaries_osx.tar.gz asset_name: spinalcordtoolbox-binaries_osx.tar.gz asset_content_type: application/gzip From 5bef2fb2edc30b4357b3b550a44a4ff8a1070464 Mon Sep 17 00:00:00 2001 From: Mathieu Guay-Paquet Date: Wed, 8 Nov 2023 15:41:57 -0500 Subject: [PATCH 5/8] Upgrade from actions/create-release to ncipollo/release-action The README for actions/create-release mentions that it's currently unmaintained, and points to some alternatives, including ncipollo/release-action, which we use in other projects already. The API is different, so this means changing how the parameters are specified for the action, but it seems like a fairly straightforward match. The bonus is that ncipollo/release-action allows attaching artifacts directly, which means: * The three steps with actions/download-artifact have to happen earlier; * The three steps with actions/upload-release-asset (which is also an archived, unmaintained action) don't need to happen at all; and * No other steps refer to the `create_release` step id, so it can be removed. --- .github/workflows/package-binaries.yml | 52 ++++++-------------------- 1 file changed, 11 insertions(+), 41 deletions(-) diff --git a/.github/workflows/package-binaries.yml b/.github/workflows/package-binaries.yml index ab24b9b..085ca5e 100644 --- a/.github/workflows/package-binaries.yml +++ b/.github/workflows/package-binaries.yml @@ -139,19 +139,6 @@ jobs: runs-on: ubuntu-latest #if: github.event_name == 'push' && github.branch_name == 'master' # only do a release on master steps: - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - # name the release with the run_id to allow multiple builds on the same branch/tag - # https://github.com/actions/create-release/issues/2#issuecomment-613591846 - tag_name: ${{ github.ref }}-${{github.run_id }} - release_name: Release ${{ github.sha }} - draft: false - prerelease: true - - uses: actions/download-artifact@v3 with: name: spinalcordtoolbox-binaries_linux @@ -164,32 +151,15 @@ jobs: with: name: spinalcordtoolbox-binaries_windows - - name: Upload Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./spinalcordtoolbox-binaries_linux.tar.gz - asset_name: spinalcordtoolbox-binaries_linux.tar.gz - asset_content_type: application/gzip - - - name: Upload Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./spinalcordtoolbox-binaries_osx.tar.gz - asset_name: spinalcordtoolbox-binaries_osx.tar.gz - asset_content_type: application/gzip - - - name: Upload Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create Release + uses: ncipollo/release-action@v1 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./spinalcordtoolbox-binaries_windows.tar.gz - asset_name: spinalcordtoolbox-binaries_windows.tar.gz - asset_content_type: application/gzip + token: ${{ secrets.GITHUB_TOKEN }} + # name the release with the run_id to allow multiple builds on the same branch/tag + # https://github.com/actions/create-release/issues/2#issuecomment-613591846 + tag: ${{ github.ref }}-${{github.run_id }} + name: Release ${{ github.sha }} + draft: false + prerelease: true + artifacts: "spinalcordtoolbox-binaries_linux.tar.gz,spinalcordtoolbox-binaries_osx.tar.gz,spinalcordtoolbox-binaries_windows.tar.gz" + artifactContentType: application/gzip From 8e49186b13b53b159696423afb689d5e78d7e0c1 Mon Sep 17 00:00:00 2001 From: Joshua Newton Date: Thu, 9 Nov 2023 12:50:21 -0500 Subject: [PATCH 6/8] `pb.yml`: Copy `on:` from `sct_tutorial_data` (`workflow-dispatch`) It looks like before this commit, we would automatically run the workflow and create the release for _any_ changes whatsoever. Then, we would pick one of those automatically-created releases and rename it to the desired release title. (Perhaps this workflow was first developed before `workflow-dispatch` even existed?) In other repos, though, we follow a "don't automatically create releases, only create releases when manually run" sort of workflow. And, given that `sct_tutorial_data` follows a similar pattern (generate artifacts, upload them to a release), I figure we can follow its example here. Plus, by manually specifying the release title, we make sure to avoid any conflicts, eliminating the need for the run ID. --- .github/workflows/package-binaries.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/package-binaries.yml b/.github/workflows/package-binaries.yml index 085ca5e..453124b 100644 --- a/.github/workflows/package-binaries.yml +++ b/.github/workflows/package-binaries.yml @@ -1,10 +1,12 @@ name: Package SCT C++ binaries on: - push: - branches: [ master ] pull_request: - branches: [ master ] + workflow_dispatch: + inputs: + release_title: + description: 'Release title (e.g. rYYYYMMDD)' + required: true # all this does is collect three dependencies, # - spinalcordtoolbox-ants which essentially a more minimal fork of https://github.com/ANTsX/ANTs @@ -155,9 +157,7 @@ jobs: uses: ncipollo/release-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - # name the release with the run_id to allow multiple builds on the same branch/tag - # https://github.com/actions/create-release/issues/2#issuecomment-613591846 - tag: ${{ github.ref }}-${{github.run_id }} + tag: ${{ github.event.inputs.release_title }} name: Release ${{ github.sha }} draft: false prerelease: true From 259b3a70561e9fe5a8816fdaabdeba69066aa9ce Mon Sep 17 00:00:00 2001 From: Joshua Newton Date: Thu, 9 Nov 2023 12:51:40 -0500 Subject: [PATCH 7/8] `pb.yml`: Only trigger release step on `workflow-dispatch` This mimics `sct_tutorial_data` et al. --- .github/workflows/package-binaries.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package-binaries.yml b/.github/workflows/package-binaries.yml index 453124b..c6d4907 100644 --- a/.github/workflows/package-binaries.yml +++ b/.github/workflows/package-binaries.yml @@ -139,7 +139,8 @@ jobs: release: needs: [build] runs-on: ubuntu-latest - #if: github.event_name == 'push' && github.branch_name == 'master' # only do a release on master + # Only attach to release if workflow is run manually. (This allows the workflow to double as a PR test.) + if: github.event_name == 'workflow_dispatch' steps: - uses: actions/download-artifact@v3 with: From 6651e78711f24c137e81151565d6a767cf5e31f5 Mon Sep 17 00:00:00 2001 From: Joshua Newton Date: Thu, 9 Nov 2023 12:53:50 -0500 Subject: [PATCH 8/8] `pb.yml`: Set `draft: true` and remove `prerelease:` Since we're no longer creating all these intermediate releases, and only creating a release when manually choosing to, I think it makes more sense to just create a draft release (rather than a non-draft prerelease). This also matches what we do for `sct_tutorial_data`. --- .github/workflows/package-binaries.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/package-binaries.yml b/.github/workflows/package-binaries.yml index c6d4907..14c9035 100644 --- a/.github/workflows/package-binaries.yml +++ b/.github/workflows/package-binaries.yml @@ -160,7 +160,6 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} tag: ${{ github.event.inputs.release_title }} name: Release ${{ github.sha }} - draft: false - prerelease: true + draft: true artifacts: "spinalcordtoolbox-binaries_linux.tar.gz,spinalcordtoolbox-binaries_osx.tar.gz,spinalcordtoolbox-binaries_windows.tar.gz" artifactContentType: application/gzip