From 0fa51bf02ea467f98b64fd9cb96dfc5cddcd6d5d Mon Sep 17 00:00:00 2001 From: Aaron Date: Sun, 22 Oct 2023 03:15:09 +0100 Subject: [PATCH 1/6] 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 2/6] 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 3/6] 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 4/6] 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 5/6] 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 6/6] 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 != ''