From f323ffc06395524c0318604d3c203ac8e5131b6b Mon Sep 17 00:00:00 2001 From: Michael Onken Date: Wed, 18 Oct 2023 13:19:49 +0200 Subject: [PATCH 1/6] Separate build and publish phase in CI. This allows for building without publishing as required for PR-triggered builds. --- .github/workflows/cmake-win.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake-win.yml b/.github/workflows/cmake-win.yml index 7de10a83..cca7ec0e 100644 --- a/.github/workflows/cmake-win.yml +++ b/.github/workflows/cmake-win.yml @@ -64,6 +64,36 @@ jobs: cd ${{ github.workspace }}\dcmqi-build\dcmqi-build cmake --build . --config Release --target PACKAGE -- /m + - uses: actions/upload-artifact@v3 + with: + name: dcmqi-build + path: ${{ github.workspace }}\dcmqi-build\dcmqi-build\dcmqi-*-win64*.zip + + # TODO remove (debug) + - name: Display structure of github workspace files + run: ls -R + working-directory: ${{ github.workspace }} + + + publish-windows: + + runs-on: windows-latest + timeout-minutes: 5 + if: github.event_name != 'pull_request' + needs: build-windows + + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: dcmqi-build + #path: ${{ github.workspace }}\dcmqi-build\dcmqi-build\dcmqi-*-win64*.zip + path: ${{ github.workspace }}\dcmqi-build\dcmqi-build + + - name: Display structure of github workspace files + run: ls -R + working-directory: ${{ github.workspace }}\dcmqi-build\dcmqi-build + - name: Publish package run: | pip install -U "scikit-ci-addons>=0.22.0" @@ -73,4 +103,4 @@ jobs: --prerelease-packages "${{ github.workspace }}\dcmqi-build\dcmqi-build\dcmqi-*-win64-*.zip" ` --prerelease-packages-clear-pattern "dcmqi-*-win64-*" ` --prerelease-packages-keep-pattern "*-*" ` - --token ${{ secrets.GA_TOKEN }} + --token ${{ secrets.RELEASE_TOKEN }} From b22ac4c87c34d483c95852d50cf27155c1264ff7 Mon Sep 17 00:00:00 2001 From: Michael Onken Date: Wed, 18 Oct 2023 14:13:08 +0200 Subject: [PATCH 2/6] Don't release if user is not QIICR. Also removed debug code, and re-inserted QIICR token name again. --- .github/workflows/cmake-win.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cmake-win.yml b/.github/workflows/cmake-win.yml index cca7ec0e..70bed6fe 100644 --- a/.github/workflows/cmake-win.yml +++ b/.github/workflows/cmake-win.yml @@ -69,17 +69,15 @@ jobs: name: dcmqi-build path: ${{ github.workspace }}\dcmqi-build\dcmqi-build\dcmqi-*-win64*.zip - # TODO remove (debug) - - name: Display structure of github workspace files - run: ls -R - working-directory: ${{ github.workspace }} - - publish-windows: runs-on: windows-latest timeout-minutes: 5 - if: github.event_name != 'pull_request' + # Only run if the event is not a pull request and the repository owner is QIICR. + # The latter is to prevent forks from publishing packages even if the owner's token + # would have sufficient privileges. + if: ${{ (github.event_name != 'pull_request') && (github.repository_owner == 'QIICR')}} + needs: build-windows steps: @@ -87,13 +85,8 @@ jobs: - uses: actions/download-artifact@v3 with: name: dcmqi-build - #path: ${{ github.workspace }}\dcmqi-build\dcmqi-build\dcmqi-*-win64*.zip path: ${{ github.workspace }}\dcmqi-build\dcmqi-build - - name: Display structure of github workspace files - run: ls -R - working-directory: ${{ github.workspace }}\dcmqi-build\dcmqi-build - - name: Publish package run: | pip install -U "scikit-ci-addons>=0.22.0" @@ -103,4 +96,4 @@ jobs: --prerelease-packages "${{ github.workspace }}\dcmqi-build\dcmqi-build\dcmqi-*-win64-*.zip" ` --prerelease-packages-clear-pattern "dcmqi-*-win64-*" ` --prerelease-packages-keep-pattern "*-*" ` - --token ${{ secrets.RELEASE_TOKEN }} + --token ${{ secrets.GA_TOKEN }} From 111f9ca5fb4f49606766877685bc0a3044fcc90c Mon Sep 17 00:00:00 2001 From: Michael Onken Date: Wed, 18 Oct 2023 16:54:16 +0200 Subject: [PATCH 3/6] List workspace content. --- .github/workflows/cmake-linux.yml | 40 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/.github/workflows/cmake-linux.yml b/.github/workflows/cmake-linux.yml index 15a758d3..e87fe02c 100644 --- a/.github/workflows/cmake-linux.yml +++ b/.github/workflows/cmake-linux.yml @@ -2,9 +2,9 @@ name: C/C++ CI Linux on: push: - branches: [ "master" ] + branches: [ "testing" ] pull_request: - branches: [ "master" ] + branches: [ "testing" ] permissions: deployments: write @@ -37,20 +37,24 @@ jobs: run: | cd docker && make dcmqi.test - - name: "Publish docker image" + - name: "Print dcmqi workspace folder" # TODO remove run: | - docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }} && \ - docker push fedorov/dcmqi:`git describe --tags --exact-match 2> /dev/null || echo "latest"` \ - || echo "skipping docker push" - - - name: "Publish linux package" - run: | - pip install -U "scikit-ci-addons>=0.22.0" - # python -m scikit-ci publish --package-name dcmqi --package-version `git - # describe --tags --exact-match 2> /dev/null || echo "latest"` --platform linux - # --commit-range ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} --repository ${{ github.event.pull_request.head.repo.full_name }} --token ${{ secrets.GITHUB_TOKEN }} --verbose - ci_addons publish_github_release QIICR/dcmqi \ - --prerelease-packages "build/dcmqi-build/dcmqi-*-linux-*.tar.gz" \ - --prerelease-packages-clear-pattern "dcmqi-*-linux-*" \ - --prerelease-packages-keep-pattern "*-*" \ - --exit-success-if-missing-token --token ${{ secrets.GA_TOKEN }} + ls -R ${{ github.workspace }} + + # - name: "Publish docker image" + # run: | + # docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }} && \ + # docker push fedorov/dcmqi:`git describe --tags --exact-match 2> /dev/null || echo "latest"` \ + # || echo "skipping docker push" + + # - name: "Publish linux package" + # run: | + # pip install -U "scikit-ci-addons>=0.22.0" + # # python -m scikit-ci publish --package-name dcmqi --package-version `git + # # describe --tags --exact-match 2> /dev/null || echo "latest"` --platform linux + # # --commit-range ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} --repository ${{ github.event.pull_request.head.repo.full_name }} --token ${{ secrets.GITHUB_TOKEN }} --verbose + # ci_addons publish_github_release QIICR/dcmqi \ + # --prerelease-packages "build/dcmqi-build/dcmqi-*-linux-*.tar.gz" \ + # --prerelease-packages-clear-pattern "dcmqi-*-linux-*" \ + # --prerelease-packages-keep-pattern "*-*" \ + # --exit-success-if-missing-token --token ${{ secrets.GA_TOKEN }} From f6076f891adfa6384f5c79116f15858b4c9e9fb1 Mon Sep 17 00:00:00 2001 From: Michael Onken Date: Wed, 18 Oct 2023 16:55:36 +0200 Subject: [PATCH 4/6] Add manual workflow run. --- .github/workflows/cmake-linux.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cmake-linux.yml b/.github/workflows/cmake-linux.yml index e87fe02c..f0c82d90 100644 --- a/.github/workflows/cmake-linux.yml +++ b/.github/workflows/cmake-linux.yml @@ -5,6 +5,7 @@ on: branches: [ "testing" ] pull_request: branches: [ "testing" ] + workflow_dispatch: permissions: deployments: write From 5df728459ea376513220b66087aca981d0f5c324 Mon Sep 17 00:00:00 2001 From: Michael Onken Date: Wed, 18 Oct 2023 17:05:23 +0200 Subject: [PATCH 5/6] Revert "Add manual workflow run." This reverts commit f6076f891adfa6384f5c79116f15858b4c9e9fb1. --- .github/workflows/cmake-linux.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cmake-linux.yml b/.github/workflows/cmake-linux.yml index f0c82d90..e87fe02c 100644 --- a/.github/workflows/cmake-linux.yml +++ b/.github/workflows/cmake-linux.yml @@ -5,7 +5,6 @@ on: branches: [ "testing" ] pull_request: branches: [ "testing" ] - workflow_dispatch: permissions: deployments: write From 974a512a9d06b43b75e7e736a77db6fa1eca769e Mon Sep 17 00:00:00 2001 From: Michael Onken Date: Wed, 18 Oct 2023 17:05:35 +0200 Subject: [PATCH 6/6] Revert "List workspace content." This reverts commit 111f9ca5fb4f49606766877685bc0a3044fcc90c. --- .github/workflows/cmake-linux.yml | 40 ++++++++++++++----------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/.github/workflows/cmake-linux.yml b/.github/workflows/cmake-linux.yml index e87fe02c..15a758d3 100644 --- a/.github/workflows/cmake-linux.yml +++ b/.github/workflows/cmake-linux.yml @@ -2,9 +2,9 @@ name: C/C++ CI Linux on: push: - branches: [ "testing" ] + branches: [ "master" ] pull_request: - branches: [ "testing" ] + branches: [ "master" ] permissions: deployments: write @@ -37,24 +37,20 @@ jobs: run: | cd docker && make dcmqi.test - - name: "Print dcmqi workspace folder" # TODO remove + - name: "Publish docker image" run: | - ls -R ${{ github.workspace }} - - # - name: "Publish docker image" - # run: | - # docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }} && \ - # docker push fedorov/dcmqi:`git describe --tags --exact-match 2> /dev/null || echo "latest"` \ - # || echo "skipping docker push" - - # - name: "Publish linux package" - # run: | - # pip install -U "scikit-ci-addons>=0.22.0" - # # python -m scikit-ci publish --package-name dcmqi --package-version `git - # # describe --tags --exact-match 2> /dev/null || echo "latest"` --platform linux - # # --commit-range ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} --repository ${{ github.event.pull_request.head.repo.full_name }} --token ${{ secrets.GITHUB_TOKEN }} --verbose - # ci_addons publish_github_release QIICR/dcmqi \ - # --prerelease-packages "build/dcmqi-build/dcmqi-*-linux-*.tar.gz" \ - # --prerelease-packages-clear-pattern "dcmqi-*-linux-*" \ - # --prerelease-packages-keep-pattern "*-*" \ - # --exit-success-if-missing-token --token ${{ secrets.GA_TOKEN }} + docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }} && \ + docker push fedorov/dcmqi:`git describe --tags --exact-match 2> /dev/null || echo "latest"` \ + || echo "skipping docker push" + + - name: "Publish linux package" + run: | + pip install -U "scikit-ci-addons>=0.22.0" + # python -m scikit-ci publish --package-name dcmqi --package-version `git + # describe --tags --exact-match 2> /dev/null || echo "latest"` --platform linux + # --commit-range ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} --repository ${{ github.event.pull_request.head.repo.full_name }} --token ${{ secrets.GITHUB_TOKEN }} --verbose + ci_addons publish_github_release QIICR/dcmqi \ + --prerelease-packages "build/dcmqi-build/dcmqi-*-linux-*.tar.gz" \ + --prerelease-packages-clear-pattern "dcmqi-*-linux-*" \ + --prerelease-packages-keep-pattern "*-*" \ + --exit-success-if-missing-token --token ${{ secrets.GA_TOKEN }}