|
| 1 | +name: Tag and Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths: |
| 9 | + - "lib/html_pipeline/version.rb" |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + env: |
| 14 | + GEM_NAME: html-pipeline |
| 15 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 16 | + GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_BOT_KEY }} |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + |
| 21 | + - name: Set up Ruby 3.1 |
| 22 | + uses: ruby/setup-ruby@v1 |
| 23 | + with: |
| 24 | + ruby-version: 3.1 |
| 25 | + bundler-cache: true |
| 26 | + |
| 27 | + - name: Configure Git |
| 28 | + run: | |
| 29 | + git config --local user.email "[email protected]" |
| 30 | + git config --local user.name "Actions Auto Build" |
| 31 | +
|
| 32 | + - name: Get current version |
| 33 | + id: version-label |
| 34 | + run: | |
| 35 | + VERSION=$(grep VERSION lib/html_pipeline/version.rb | head -n 1 | cut -d'"' -f2) |
| 36 | + echo "version=${VERSION}" >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + - name: Create tag |
| 39 | + run: | |
| 40 | + git tag -a v${{ steps.version-label.outputs.version }} -m "Release v${{ steps.version-label.outputs.version }}" |
| 41 | + git push origin --tags |
| 42 | +
|
| 43 | + - name: Generate CHANGELOG.md |
| 44 | + id: changelog |
| 45 | + run: script/generate_changelog |
| 46 | + |
| 47 | + - name: Commit & Push Changelog |
| 48 | + run: | |
| 49 | + git config --local user.email "[email protected]" |
| 50 | + git config --local user.name "Actions Auto Build" |
| 51 | + git add -f CHANGELOG.md |
| 52 | + git commit -m "docs: update changelog" || true |
| 53 | + git push |
| 54 | +
|
| 55 | + - name: Publish release |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + run: | |
| 59 | + gh release create v${{ steps.version-label.outputs.version }} --generate-notes |
| 60 | +
|
| 61 | + - name: Publish to RubyGems |
| 62 | + run: | |
| 63 | + mkdir -p $HOME/.gem |
| 64 | + touch $HOME/.gem/credentials |
| 65 | + chmod 0600 $HOME/.gem/credentials |
| 66 | + printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials |
| 67 | + bundle exec rake package |
| 68 | + for gem in pkg/html-pipeline-${{ steps.version-label.outputs.version }}*.gem ; do |
| 69 | + gem push "$gem" --host https://rubygems.org |
| 70 | + done |
0 commit comments