Skip to content

Commit

Permalink
Feat: auto release (#7)
Browse files Browse the repository at this point in the history
* release-artifacts.yml

* fix: permission denied error
  • Loading branch information
sargeantPig authored Oct 22, 2023
1 parent 4d64747 commit 1e15a74
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@ 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

0 comments on commit 1e15a74

Please sign in to comment.