diff --git a/.github/workflows/gem_release.yml b/.github/workflows/gem_release.yml deleted file mode 100644 index 59378d5b..00000000 --- a/.github/workflows/gem_release.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: "Gem Release" - -on: - workflow_dispatch: - inputs: - target: - description: "The target for the release. This can be a commit sha or a branch." - required: false - default: "main" - -jobs: - release: - uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release.yml@main" - with: - target: "${{ github.event.inputs.target }}" - secrets: "inherit" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b5b0b34e..06ba30fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,6 +55,26 @@ jobs: - name: "Create release" run: | - gh release create v${{ steps.get_version.outputs.version }} ./output/* --title v${{ steps.get_version.outputs.version }} -F OUTPUT.md + gh release create v${{ steps.get_version.outputs.version }} ./pkg/* --title v${{ steps.get_version.outputs.version }} -F OUTPUT.md env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Publish gem to rubygems" + run: | + gem push ./pkg/*.gem + env: + GEM_HOST_API_KEY: '${{ secrets.GEM_HOST_API_KEY }}' + + - name: "Publish to GitHub Package" + run: | + echo "Setting up access to RubyGems" + mkdir -p ~/.gem + touch ~/.gem/credentials + chmod 600 ~/.gem/credentials + + echo "Logging in to GitHub Package Registry" + echo "---" > ~/.gem/credentials + echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials + + echo "Pushing gem to GitHub Package Registry" + gem push --key "github" --host "https://rubygems.pkg.github.com/${{github.repository_owner}}" ./pkg/*.gem diff --git a/.gitignore b/.gitignore index 10306e72..cd9fa04e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ log/ tmp/ output/ vendor/ +pkg/ diff --git a/Rakefile b/Rakefile index 83192151..95510713 100644 --- a/Rakefile +++ b/Rakefile @@ -149,7 +149,7 @@ task build: [:gem_revendor] do require 'digest' project_dir = File.dirname(__FILE__) - output_dir = File.join(project_dir, 'output') + output_dir = File.join(project_dir, './pkg/') file_list = ['lib', 'vendor', 'puppet-languageserver', 'puppet-debugserver', 'puppet-languageserver-sidecar', 'LICENSE'] # Remove files in the list that do not exist. @@ -180,6 +180,11 @@ task build: [:gem_revendor] do File.open(filepath + '.sha256', 'wb') { |file| file.write(sha) } end puts "Created checksums" + + puts 'Building gem..' + require 'bundler/gem_tasks' + Rake::Task['build'].invoke + puts 'Gem built' end task :default => [:test]