From 29e4efc6accd30ced2c2917813f05a127114c5c9 Mon Sep 17 00:00:00 2001 From: thde Date: Wed, 27 Sep 2023 15:51:28 +0200 Subject: [PATCH] fix: gem push --- .github/workflows/publish.yml | 45 ----------------------------------- .github/workflows/release.yml | 35 ++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 46 deletions(-) delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 2b9f6b3..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: publish - -on: - workflow_dispatch: - push: - tags: - - "*" - -permissions: - packages: write - contents: read - -jobs: - build: - name: publish - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.2 - - run: bundle install - - name: Publish to GPR - run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials - gem build *.gemspec - gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem - env: - GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}" - OWNER: ${{ github.repository_owner }} - CI_COMMIT_TAG: ${{github.ref_name}} - - name: Publish to RubyGems - run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials - gem build *.gemspec - gem push *.gem - env: - GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}" - CI_COMMIT_TAG: ${{github.ref_name}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a426373..c73e3cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,15 @@ name: release on: + workflow_dispatch: push: branches: - main - master - pull_request: permissions: contents: write + actions: write jobs: release: @@ -21,3 +22,35 @@ jobs: with: allow-initial-development-versions: true github-token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: check if tag has been created + run: test -n "$(git tag --points-at HEAD)" || ( gh run cancel ${{ github.run_id }} && gh run watch ${{ github.run_id }} ) + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 + - run: bundle install + - run: gem build *.gemspec + env: + CI_COMMIT_TAG: ${{github.ref_name}} + - name: prepare gem credential + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + - name: publish to GPR + run: | + printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials + gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem + env: + GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}" + OWNER: ${{ github.repository_owner }} + - name: publish to RubyGems + run: | + printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials + gem push *.gem + env: + GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"