diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ce3a96e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +--- +name: Release + +on: + workflow_call: + inputs: + allowed_owner: + description: 'Only allow this owner. Used to prevent releasing on forks' + required: true + type: 'string' + ruby_version: + description: 'Ruby version used to build' + default: '3.0' + type: 'string' + secrets: + api_key: + description: 'The Rubygems API key' + required: true + +jobs: + release: + runs-on: ubuntu-latest + if: github.repository_owner == inputs.allowed_owner + steps: + - uses: actions/checkout@v4 + - name: 'Install Ruby ${{ inputs.ruby_version }}' + uses: ruby/setup-ruby@v1 + with: + ruby-version: '${{ inputs.ruby_version }}' + - name: Build gem + run: gem build *.gemspec + - name: Publish gem to rubygems.org + run: gem push *.gem + env: + GEM_HOST_API_KEY: '${{ secrets.api_key }}' diff --git a/README.md b/README.md index 1756445..dc56d6a 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,26 @@ Shared config and templates. For details on org shared templates, see: [documentation](https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization). + +## Gem release + +To release a gem, use the following workflow + +``` +name: Release + +on: + push: + # Pattern matched against refs/tags + tags: + - '**' + +jobs: + release: + name: Release gem + uses: fog/.github/.github/workflows/ci.yml@v1.5.0 + with: + allowed_owner: MY_USERNAME + secrets: + api_key: ${{ secrets.RUBYGEM_API_KEY }} +```