https://github.com/maremare/try-gh-release-in-actions
๐งช๐ GitHub Actions ใงใฎ gh release ใใใใ
https://github.com/maremare/try-gh-release-in-actions
Last synced: 15 days ago
JSON representation
๐งช๐ GitHub Actions ใงใฎ gh release ใใใใ
- Host: GitHub
- URL: https://github.com/maremare/try-gh-release-in-actions
- Owner: MareMare
- License: mit
- Created: 2023-12-25T06:51:30.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-26T16:17:51.000Z (about 1 year ago)
- Last Synced: 2025-07-26T17:19:43.687Z (2 months ago)
- Language: C#
- Homepage:
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# try-gh-release-in-actions
๐งช๐ GitHub Actions ใง `gh release` ใ่ฉฆใใฆใฟใพใใ* [Using GitHub CLI in workflows](https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows)
* [Assigning permissions to jobs](https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs)
* [`gh release create`](https://cli.github.com/manual/gh_release_create)
* [`gh release upload`](https://cli.github.com/manual/gh_release_upload)## ๐ก `gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable.`
```yml
env:
GH_TOKEN: ${{ github.token }}
```## ๐ก `HTTP 403: Resource not accessible by integration`
```ps1
Run gh release create v0.0.1-beta.4 --generate-notes --draft --prerelease
HTTP 403: Resource not accessible by integration (https://api.github.com/repos/MareMare/try-gh-release-in-actions/releases)
Error: Process completed with exit code 1.
```๐
`Settings > Actions > General > Workflow permissions`
![]()
## `gh release upload` ใงใชใชใผในใขใปใใใซใขใใใญใผใใใๆนๆณ
ใขใใใญใผใใใใขใปใใใฏไปฅไธใซๆ ผ็ดใใใฆใใใใจใๅๆใจใใพใใ
```sh
.
โโartifacts
Sandbox.0.0.0-beta.nupkg
Sandbox.0.0.0-beta.snupkg
```### `$(ls **/*.*nupkg)`
> [!NOTE]
> `bash` and/or `pwsh````yml
run: gh release upload ${{ env.TAG_NAME }} $(ls **/*.*nupkg)
```### `$(find artifacts -type f)`
> [!NOTE]
> `bash` only```yml
run: gh release upload ${{ env.TAG_NAME }} $(find artifacts -type f)
shell: bash
```### `find artifacts -type f | xargs`
> [!NOTE]
> `bash` only```yml
run: find artifacts -type f | xargs gh release upload ${{ env.TAG_NAME }}
shell: bash
```ใใใใใกใข๏ผ
* ใญใผใซใซใฎ `pwsh` ใงใใใใ
```ps1
$TAG_NAME="v0.0.1-beta.1"
git tag $TAG_NAME
git push --tags# ๐ฆ Pack
dotnet pack --output artifacts# ๐ Create Release $TAG_NAME
gh release create $TAG_NAME --generate-notes --draft --prerelease
# โ Upload assets
gh release upload $TAG_NAME $(ls **/*.*nupkg)
```* ใญใผใซใซใฎ `bash` ใงใใใใ
```sh
export TAG_NAME="v0.0.1-beta.2"
git tag $TAG_NAME
git push --tags# ๐ฆ Pack
dotnet pack --output artifacts# ๐ Create Release $TAG_NAME
gh release create $TAG_NAME --generate-notes --draft --prerelease
# โ Upload assets
gh release upload $TAG_NAME $(ls **/*.*nupkg)
```* GitHub Actions ใงใใใใ (`bash`)
```yml
name: Sandbox
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag name. eg) "v0.0.1, v0.0.1-beta.1"'
default: 'v0.0.1-beta.1'
required: falseenv:
TAG_NAME: ${{ inputs.tag || github.ref_name }}
CONFIGURATION: Release
DOTNET_VERSION: "8.0.x"concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: truejobs:
sandbox:
name: ๐ป ใใใใ
runs-on: ubuntu-latest
if: startsWith(inputs.tag || github.ref_name, 'v')
steps:
- name: ๐ Checkout
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
filter: tree:0
- name: โจ Setup .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: ๐ ๏ธ Build
run: dotnet build --configuration ${{ env.CONFIGURATION }}
- name: ๐งช Test
run: dotnet test --configuration ${{ env.CONFIGURATION }} --no-build --verbosity normal --collect:"XPlat Code Coverage" --logger trx --results-directory coverage --filter 'Category!=local'- name: ๐ฆ Pack
run: dotnet pack --output ./artifacts
- name: ๐ Create Release ${{ env.TAG_NAME }}
run: gh release create ${{ env.TAG_NAME }} --generate-notes --draft --prerelease
- name: โ Upload assets
run: gh release upload ${{ env.TAG_NAME }} $(ls **/*.*nupkg)
shell: bash
- run: echo "### โ Release succeeded! ${{ env.TAG_NAME }} ๐" >> $GITHUB_STEP_SUMMARY
```## ๅ่
* [gh release create wildcard '*' not working on windows](https://github.com/cli/cli/issues/5099)
* [cli/cli/.github/workflows/deployment.yml](https://github.com/cli/cli/blob/541ce0e5b49269b8b39707b3d16cfbd01d79b9a0/.github/workflows/deployment.yml#L344C43-L344C49)
* [Bashใง '\*\*' ใฎๅฑ้ใONใซใใ \(globstar\) \- ใใใใๅๅฟ้ฒๆฅ่จ](https://devlights.hatenablog.com/entry/2023/02/20/073000)