fix #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Gem | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.3" | |
| - name: Extract version from tag | |
| id: get_version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Update version.rb | |
| run: | | |
| VERSION=${{ steps.get_version.outputs.version }} | |
| sed -i "s/VERSION = '.*'/VERSION = '$VERSION'/" lib/bundleup/version.rb | |
| cat lib/bundleup/version.rb | |
| - name: Update CHANGELOG.md | |
| run: | | |
| VERSION=${{ steps.get_version.outputs.version }} | |
| DATE=$(date +%Y-%m-%d) | |
| # Check if version already exists in changelog | |
| if ! grep -q "## \[$VERSION\]" CHANGELOG.md; then | |
| # Add new version entry after the first "## [" line | |
| sed -i "0,/^## \[/s//## [$VERSION] - $DATE\n###\n\n&/" CHANGELOG.md | |
| fi | |
| - name: Commit version changes | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add lib/bundleup/version.rb CHANGELOG.md | |
| git diff --staged --quiet || git commit -m "Update version to ${{ steps.get_version.outputs.version }}" | |
| - name: Push changes | |
| uses: ad-m/github-push-action@master | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: main | |
| tags: false | |
| - name: Install dependencies | |
| run: | | |
| bundle install | |
| - name: Build gem | |
| run: | | |
| gem build bundleup-sdk.gemspec | |
| - 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 push *.gem | |
| env: | |
| GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_AUTH_TOKEN }}" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: "*.gem" | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |