name: Ruby Gem Publish

on:
  push:
    tags: 
      - '*'
jobs:
  publish:
    runs-on: ubuntu-latest
    env:
      GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
    
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0 # need all the commits
      
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '2.6'
          bundler-cache: false
      
      - uses: actions/setup-node@v2
      
      - name: Clean
        run: |
          rm -f *.gem
          git checkout lib/smartystreets_ruby_sdk/version.rb
      
      - name: Dependencies
        run: |
          gem install minitest
      
      - name: Test
        run: |
          rake test
      
      - name: Set Environment Variable
        run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

      - name: Grab Version
        run: |
          echo "VERSION = \"${{ env.RELEASE_VERSION }}\"" >> version.rb \
          && cat version.rb \
#          && gem build *.gemspec \
#          && git checkout version.rb
     
      - name: Push to rubygems.org
        run: |
          chmod 0600 /root/.gem/credentials
          gem push *.gem

name: Ruby Gem Publish

on:
  push:
    tags: 
      - '*'
jobs:
  publish:
    runs-on: ubuntu-latest
    env:
      GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
    
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0 # need all the commits
      
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '2.6'
          bundler-cache: false
      
      - uses: actions/setup-node@v2
      
      - name: Clean
        run: |
          rm -f *.gem
          git checkout lib/smartystreets_ruby_sdk/version.rb
      
      - name: Dependencies
        run: |
          gem install minitest
      
      - name: Test
        run: |
          rake test
      
      - name: Set Environment Variable
        run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

      - name: Grab Version
        run: |
          echo "VERSION = \"${{ env.RELEASE_VERSION }}\"" >> version.rb \
          && cat version.rb \
#          && gem build *.gemspec \
#          && git checkout version.rb
     
      - name: Push to rubygems.org
        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
#          chmod 0600 /root/.gem/credentials
          gem build *.gemspec
          gem push *.gem
        env:
          GEM_HOST_API_KEY: "${{secrets.GEM_HOST_API_KEY}}"

Add credentials from github secrets
Add credentials from github secrets
