From 0fa51bf02ea467f98b64fd9cb96dfc5cddcd6d5d Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 03:15:09 +0100 Subject: [PATCH 01/13] release-artifacts.yml --- .github/workflows/release-artifacts.yml | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/release-artifacts.yml diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml new file mode 100644 index 0000000..b645f0b --- /dev/null +++ b/.github/workflows/release-artifacts.yml @@ -0,0 +1,35 @@ +name: Release Artifacts Upload +on: + push: + branches: + - main +jobs: + upload-release-artifacts: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Install GitHub CLI + run: | + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg + echo "deb [signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg arch=amd64] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null + apt update + apt install gh + - name: Upload Release Artifacts + if: contains(github.event.head_commit.message, 'refs/pull/') && contains(github.event.head_commit.message, 'release') + run: | + # Replace 'release' with your custom label name if needed + label="release" + # Use 'jq' to extract the PR number from the commit message + pr_number=$(echo ${{ github.event.head_commit.message }} | grep -oE 'pull/[0-9]+' | cut -d'/' -f2) + # Check if the PR has the specified label + if gh pr view $pr_number --json labels -q ".[].name" | grep -q "$label"; then + # Replace these paths with the actual locations of your release artifacts + gh release upload ${{ github.event.ref }} ./artifact/RTWRand-macos.zip + gh release upload ${{ github.event.ref }} ./artifact/RTWRand-windows.zip + gh release upload ${{ github.event.ref }} ./artifact/RTWRand-linux.zip + fi From b201b7e846572b0bc45da1ef0bae141e117bb3a6 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 03:27:27 +0100 Subject: [PATCH 02/13] fix: permission denied error --- .github/workflows/release-artifacts.yml | 38 +++++++++++++------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index b645f0b..fcc64eb 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -9,27 +9,29 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '14' - - name: Install GitHub CLI + - name: Set up GitHub CLI run: | - curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg - echo "deb [signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg arch=amd64] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null - apt update - apt install gh - - name: Upload Release Artifacts - if: contains(github.event.head_commit.message, 'refs/pull/') && contains(github.event.head_commit.message, 'release') + # Install GitHub CLI + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 + sudo apt-add-repository https://cli.github.com/packages + sudo apt update + sudo apt install gh + shell: bash + - name: Check for Release Creation + id: check-release run: | - # Replace 'release' with your custom label name if needed label="release" - # Use 'jq' to extract the PR number from the commit message pr_number=$(echo ${{ github.event.head_commit.message }} | grep -oE 'pull/[0-9]+' | cut -d'/' -f2) - # Check if the PR has the specified label if gh pr view $pr_number --json labels -q ".[].name" | grep -q "$label"; then - # Replace these paths with the actual locations of your release artifacts - gh release upload ${{ github.event.ref }} ./artifact/RTWRand-macos.zip - gh release upload ${{ github.event.ref }} ./artifact/RTWRand-windows.zip - gh release upload ${{ github.event.ref }} ./artifact/RTWRand-linux.zip + # Release label applied, check for release creation + release_url=$(gh pr view $pr_number --json links.html -q ".[] | select(.rel == \"html\") | .href") + release_id=$(basename $release_url) + echo "::set-output name=release_id::$release_id" fi + shell: bash + - name: Upload Release Artifacts + if: steps.check-release.outputs.release_id != '' + run: | + gh release upload ${{ steps.check-release.outputs.release_id }} ./artifact/RTWRand-macos.zip + gh release upload ${{ steps.check-release.outputs.release_id }} ./artifact/RTWRand-windows.zip + gh release upload ${{ steps.check-release.outputs.release_id }} ./artifact/RTWRand-linux.zip From f99b042175383035fb67dc3bf6a20a0a69ea065c Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 03:38:55 +0100 Subject: [PATCH 03/13] retry --- .github/workflows/release-artifacts.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index fcc64eb..91d70cf 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -9,13 +9,12 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Set up GitHub CLI + - name: Install GitHub CLI run: | - # Install GitHub CLI - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 - sudo apt-add-repository https://cli.github.com/packages - sudo apt update - sudo apt install gh + # Download and install GitHub CLI + wget https://github.com/cli/cli/releases/latest/download/gh_linux_amd64.deb + sudo dpkg -i gh_linux_amd64.deb + rm gh_linux_amd64.deb shell: bash - name: Check for Release Creation id: check-release From 2eae6ec27fd00c85ebe024f042e51396a52973d0 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 03:45:08 +0100 Subject: [PATCH 04/13] remove install gh cli --- .github/workflows/release-artifacts.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index 91d70cf..c9f744d 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -9,13 +9,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Install GitHub CLI - run: | - # Download and install GitHub CLI - wget https://github.com/cli/cli/releases/latest/download/gh_linux_amd64.deb - sudo dpkg -i gh_linux_amd64.deb - rm gh_linux_amd64.deb - shell: bash - name: Check for Release Creation id: check-release run: | From 9f404b09ba4d1b0e251e97ac723b82163ea8575b Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 03:50:22 +0100 Subject: [PATCH 05/13] fix: typo --- .github/workflows/release-artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index c9f744d..d5a616d 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -19,7 +19,7 @@ jobs: release_url=$(gh pr view $pr_number --json links.html -q ".[] | select(.rel == \"html\") | .href") release_id=$(basename $release_url) echo "::set-output name=release_id::$release_id" - fi + shell: bash - name: Upload Release Artifacts if: steps.check-release.outputs.release_id != '' From ae1a7a404d17395ac80874a658df134d57995c5f Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 03:58:04 +0100 Subject: [PATCH 06/13] retry --- .github/workflows/release-artifacts.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index d5a616d..7d30def 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -14,12 +14,13 @@ jobs: run: | label="release" pr_number=$(echo ${{ github.event.head_commit.message }} | grep -oE 'pull/[0-9]+' | cut -d'/' -f2) + if gh pr view $pr_number --json labels -q ".[].name" | grep -q "$label"; then - # Release label applied, check for release creation - release_url=$(gh pr view $pr_number --json links.html -q ".[] | select(.rel == \"html\") | .href") - release_id=$(basename $release_url) - echo "::set-output name=release_id::$release_id" - + release_url=$(gh pr view $pr_number --json links.html -q ".[] | select(.rel == \"html\") | .href") + release_id=$(basename $release_url) + echo "::set-output name=release_id::$release_id" + fi + shell: bash - name: Upload Release Artifacts if: steps.check-release.outputs.release_id != '' From 7e1bcd8b3ecb46e41b98ecbc66f77b4b81f943f4 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 04:01:55 +0100 Subject: [PATCH 07/13] retry --- .github/workflows/release-artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index 7d30def..18f7e9b 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -13,7 +13,7 @@ jobs: id: check-release run: | label="release" - pr_number=$(echo ${{ github.event.head_commit.message }} | grep -oE 'pull/[0-9]+' | cut -d'/' -f2) + pr_number=$(echo "${{ github.event.head_commit.message }}" | grep -oE 'pull/[0-9]+' | cut -d'/' -f2) if gh pr view $pr_number --json labels -q ".[].name" | grep -q "$label"; then release_url=$(gh pr view $pr_number --json links.html -q ".[] | select(.rel == \"html\") | .href") From 4db79cd3994b6194c5dcaaa52178785b3481d478 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 04:04:56 +0100 Subject: [PATCH 08/13] retry --- .github/workflows/release-artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index 18f7e9b..d851efe 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -21,7 +21,7 @@ jobs: echo "::set-output name=release_id::$release_id" fi - shell: bash + shell: bash --noprofile --norc -e -o pipefail - name: Upload Release Artifacts if: steps.check-release.outputs.release_id != '' run: | From 9fe9391f687a415204294af88b15fc066b656158 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 15:49:13 +0100 Subject: [PATCH 09/13] better way of releasing the artifact --- .github/workflows/release-artifacts.yml | 38 ++++++++++++------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index d851efe..26b45cc 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -1,30 +1,28 @@ -name: Release Artifacts Upload +name: Upload Release Artifacts + on: - push: - branches: - - main + release: + types: + - published + jobs: upload-release-artifacts: runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v2 - - name: Check for Release Creation - id: check-release + + - name: Get Release Tag + id: get-release-tag run: | - label="release" - pr_number=$(echo "${{ github.event.head_commit.message }}" | grep -oE 'pull/[0-9]+' | cut -d'/' -f2) - - if gh pr view $pr_number --json labels -q ".[].name" | grep -q "$label"; then - release_url=$(gh pr view $pr_number --json links.html -q ".[] | select(.rel == \"html\") | .href") - release_id=$(basename $release_url) - echo "::set-output name=release_id::$release_id" - fi - - shell: bash --noprofile --norc -e -o pipefail + release_tag="${{ github.event.release.tag_name }}" + echo "Uploading artifacts to release with tag: $release_tag" + shell: bash + - name: Upload Release Artifacts - if: steps.check-release.outputs.release_id != '' run: | - gh release upload ${{ steps.check-release.outputs.release_id }} ./artifact/RTWRand-macos.zip - gh release upload ${{ steps.check-release.outputs.release_id }} ./artifact/RTWRand-windows.zip - gh release upload ${{ steps.check-release.outputs.release_id }} ./artifact/RTWRand-linux.zip + release_tag="${{ steps.get-release-tag.outputs.release_tag }}" + # Use the release tag to determine which release to upload to + # Add the necessary commands for uploading artifacts + shell: bash From 7018985be4b547afafff9919d039fbd89786ff00 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 18:34:00 +0100 Subject: [PATCH 10/13] correctly get the tag --- .github/workflows/release-artifacts.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index 26b45cc..9570550 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -21,8 +21,14 @@ jobs: shell: bash - name: Upload Release Artifacts + if: ${{ steps.get-release-tag.outputs.release_tag != '' }} run: | release_tag="${{ steps.get-release-tag.outputs.release_tag }}" # Use the release tag to determine which release to upload to - # Add the necessary commands for uploading artifacts + + # Assuming $release_tag contains the tag name of the release + # Replace 'your-artifact-directory' with the path to your artifact directory + gh release upload "$release_tag" ./artifact/RTWRand-macos.zip --clobber + gh release upload "$release_tag" ./artifact/RTWRand-windows.zip --clobber + gh release upload "$release_tag" ./artifact/RTWRand-linux.zip --clobber shell: bash From 23ecb3f22b8f4d12148f84150f074cf455b2479d Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 23 Oct 2023 02:39:28 +0100 Subject: [PATCH 11/13] combined workflow --- .github/workflows/google-release-please.yml | 27 -------- .github/workflows/release-artifacts.yml | 34 ---------- .github/workflows/release-creation.yml | 72 +++++++++++++++++++++ 3 files changed, 72 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/google-release-please.yml delete mode 100644 .github/workflows/release-artifacts.yml create mode 100644 .github/workflows/release-creation.yml diff --git a/.github/workflows/google-release-please.yml b/.github/workflows/google-release-please.yml deleted file mode 100644 index d429c89..0000000 --- a/.github/workflows/google-release-please.yml +++ /dev/null @@ -1,27 +0,0 @@ -on: - workflow_run: - workflows: - - "macos-build-test.yml" - - "windows-build-test.yml" - - "linux-build-test.yml" - types: - - completed - push: - branches: - - main - -name: release-please -jobs: - release-please: - runs-on: ubuntu-latest - steps: - - uses: google-github-actions/release-please-action@v3 - id: release - with: - release-type: simple - - name: Upload Release Artifact - if: ${{ steps.release.outputs.release_created }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: - gh release upload ${{ steps.release.outputs.tag_name }} ./artifact/RTWRand-macos.zip ./artifact/RTWRand-windows.zip ./artifact/RTWRand-linux.zip \ No newline at end of file diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml deleted file mode 100644 index 9570550..0000000 --- a/.github/workflows/release-artifacts.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Upload Release Artifacts - -on: - release: - types: - - published - -jobs: - upload-release-artifacts: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Get Release Tag - id: get-release-tag - run: | - release_tag="${{ github.event.release.tag_name }}" - echo "Uploading artifacts to release with tag: $release_tag" - shell: bash - - - name: Upload Release Artifacts - if: ${{ steps.get-release-tag.outputs.release_tag != '' }} - run: | - release_tag="${{ steps.get-release-tag.outputs.release_tag }}" - # Use the release tag to determine which release to upload to - - # Assuming $release_tag contains the tag name of the release - # Replace 'your-artifact-directory' with the path to your artifact directory - gh release upload "$release_tag" ./artifact/RTWRand-macos.zip --clobber - gh release upload "$release_tag" ./artifact/RTWRand-windows.zip --clobber - gh release upload "$release_tag" ./artifact/RTWRand-linux.zip --clobber - shell: bash diff --git a/.github/workflows/release-creation.yml b/.github/workflows/release-creation.yml new file mode 100644 index 0000000..d25e836 --- /dev/null +++ b/.github/workflows/release-creation.yml @@ -0,0 +1,72 @@ +on: + workflow_run: + workflows: + - "macos-build-test.yml" + - "windows-build-test.yml" + - "linux-build-test.yml" + types: + - completed + push: + branches: + - main +name: combined-release-workflow + +jobs: + combined-release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Release Please + uses: google-github-actions/release-please-action@v3 + with: + release-type: simple + + - name: Check Release Creation + id: check-release-created + run: | + if gh release view "${{ steps.release.outputs.tag_name }}" > /dev/null; then + echo "Release was created." + else + echo "Release not created. Exiting." + exit 1 + fi + shell: bash + + - name: Publish Windows Build + run: dotnet publish ${{github.workspace}}/RTWLib_CLI/RTWLib_CLI.csproj -c Release -r win-x64 --self-contained true -o ./publish/win-x64 + + - name: Publish Windows Artifact + uses: actions/upload-artifact@v2 + with: + name: RTWRand-windows + path: ${{github.workspace}}/publish/win-x64 + + - name: Publish macOS Build + run: dotnet publish ${{github.workspace}}/RTWLib_CLI/RTWLib_CLI.csproj -c Release -r osx-x64 --self-contained true -o ./publish/osx-x64 + + - name: Publish macOS Artifact + uses: actions/upload-artifact@v2 + with: + name: RTWRand-macos + path: ${{github.workspace}}/publish/osx-64 + + - name: Publish Linux Build + run: dotnet publish ${{github.workspace}}/RTWLib_CLI/RTWLib_CLI.csproj -c Release -r linux-x64 --self-contained true -o ./publish/linux-x64 + + - name: Publish linux Artifact + uses: actions/upload-artifact@v2 + with: + name: RTWRand-linux + path: ${{github.workspace}}/publish/linux-x64 + + + - name: Upload Release Artifacts + run: | + release_tag="${{ steps.release.outputs.tag_name }}" + gh release upload "$release_tag" ${{github.workspace}}/publish/win-x64/* --clobber + gh release upload "$release_tag" ${{github.workspace}}/publish/osx-x64/* --clobber + gh release upload "$release_tag" ${{github.workspace}}/publish/linux-x64/* --clobber + shell: bash + From 0e7253bf941455b221274197e24c4cbe0f8b8053 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 23 Oct 2023 02:45:16 +0100 Subject: [PATCH 12/13] added github token --- .github/workflows/release-creation.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release-creation.yml b/.github/workflows/release-creation.yml index d25e836..f19f4cb 100644 --- a/.github/workflows/release-creation.yml +++ b/.github/workflows/release-creation.yml @@ -11,6 +11,9 @@ on: - main name: combined-release-workflow +env: + GH_TOKEN: ${{ github.token }} + jobs: combined-release: runs-on: ubuntu-latest From d9554e6e72b0d7f8edfa8a5a6ece8e2b6ddbeb57 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 23 Oct 2023 02:50:07 +0100 Subject: [PATCH 13/13] check release exists --- .github/workflows/release-creation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-creation.yml b/.github/workflows/release-creation.yml index f19f4cb..53c9632 100644 --- a/.github/workflows/release-creation.yml +++ b/.github/workflows/release-creation.yml @@ -28,6 +28,7 @@ jobs: - name: Check Release Creation id: check-release-created + if: ${{ steps.release.outputs.tag_name != '' }} run: | if gh release view "${{ steps.release.outputs.tag_name }}" > /dev/null; then echo "Release was created."