From e75a1d8f796541e8029a1dffdc0fef899a4ce7e0 Mon Sep 17 00:00:00 2001 From: Richard Liang Date: Thu, 21 Nov 2024 15:49:52 -0800 Subject: [PATCH] Added a step to add the gem as an asset to the release; also streamlined the environment variables. --- .github/workflows/build_and_publish_gem.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_publish_gem.yml b/.github/workflows/build_and_publish_gem.yml index 5309177..2d4c1f1 100644 --- a/.github/workflows/build_and_publish_gem.yml +++ b/.github/workflows/build_and_publish_gem.yml @@ -7,6 +7,12 @@ on: jobs: build_gem: runs-on: ubuntu-latest + + env: + CFE_GOTOH_VERSION: ${{ github.ref_name }} + BUILD_PATH: ${{ github.workspace }}/ruby + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: - name: Checkout code from repo uses: actions/checkout@v4 @@ -25,15 +31,19 @@ jobs: cacheFrom: ghcr.io/cfe-lab/gotoh_devcontainer runCmd: cd /workspaces/gotoh/ruby && bash build_gem.bash env: | - CFE_GOTOH_VERSION=${{ github.ref_name }} + CFE_GOTOH_VERSION - name: Publish gem to Github Packages run: | mkdir -p $HOME/.gem touch $HOME/.gem/credentials chmod 0600 $HOME/.gem/credentials - printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials - gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem + printf -- "---\n:github: Bearer ${GH_TOKEN}\n" > $HOME/.gem/credentials + gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} ${BUILD_PATH}/*.gem env: - GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }} OWNER: ${{ github.repository_owner }} + + - name: Add gem as a release asset + run: gh release upload $CFE_GOTOH_VERSION ${BUILD_PATH}/*.gem + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}