Ruby -- v1.0.1 -- drop support for 2.7 (#903) #62
This file contains 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: Ruby 🔻💎🔻 Test 🦂 Build 🧱 Release 🚰 and Publish 📦 | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- 'ruby/**' | |
- '!ruby/**.md' | |
- '!ruby/.vscode/**' | |
- '.github/workflows/ruby-*' | |
workflow_dispatch: | |
permissions: {} | |
defaults: | |
run: | |
shell: bash | |
working-directory: ruby | |
env: | |
development_ruby_version: 3.3.6 | |
disable_rvm_proctoring: INSTALL_RUBY='' _='' | |
jobs: | |
context: | |
name: GitHub 🐱👤 Context 📑 | |
uses: ./.github/workflows/github-context.yaml | |
test: | |
name: Ruby 🔻💎🔻 Test 🦂 | |
permissions: | |
actions: read | |
contents: read | |
security-events: write | |
uses: ./.github/workflows/ruby-test.yaml | |
workflow-conditions: | |
name: 🛑🛑🛑 Stop builds that didn't change the release version 🛑🛑🛑 | |
runs-on: ubuntu-latest | |
outputs: | |
version-file-changed: ${{ steps.version-file-check.outputs.version-file-changed }} | |
version-tag-exists: ${{ steps.version-tag-exists.outputs.version-tag-exists }} | |
steps: | |
- name: 🏁 Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
fetch-depth: 2 | |
- name: Check if version files changed | |
id: version-file-check | |
run: | | |
export VERSION_FILE="ruby/lib/collatz/version.rb" | |
[ "$(git diff HEAD^1.. --name-only | grep -e "^$VERSION_FILE$")" == "$VERSION_FILE" ] && echo "version-file-changed=${{toJSON(true)}}" >> $GITHUB_OUTPUT || echo "version-file-changed=${{toJSON(false)}}" >> $GITHUB_OUTPUT | |
- name: Notify on version-file-check | |
run: echo "::Notice::version-file-changed is ${{ fromJSON(steps.version-file-check.outputs.version-file-changed) }}" | |
- name: Check if version specified in version file has not released. | |
id: version-tag-exists | |
run: | | |
git fetch --tags | |
export VER=$(grep lib/collatz/version.rb -e "VERSION" | cut -d \" -f 2) | |
[ -z "$(git tag -l "ruby-v$VER")" ] && echo "version-tag-exists=${{toJSON(false)}}" >> $GITHUB_OUTPUT || echo "version-tag-exists=${{toJSON(true)}}" >> $GITHUB_OUTPUT | |
- name: Notify on version-tag-exists | |
run: echo "::Notice::version-tag-exists is ${{ fromJSON(steps.version-tag-exists.outputs.version-tag-exists) }}" | |
# Now any step that should only run on the version change can use | |
# "needs: [workflow-conditions]" Which will yield the condition checks below. | |
# We want to "release" automatically if "version-file-changed" is true on push | |
# Or manually if workflow_dispatch. BOTH need "version-tag-exists" is false. | |
build: | |
name: Ruby 🔻💎🔻 Build 🧱 | |
needs: [test, workflow-conditions] | |
if: >- | |
${{ ((fromJSON(needs.workflow-conditions.outputs.version-file-changed) == true && github.event_name == 'push') || | |
github.event_name == 'workflow_dispatch') && fromJSON(needs.workflow-conditions.outputs.version-tag-exists) == false }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🏁 Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: 🔻💎🔻 Set up Ruby | |
uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # v1.221.0 | |
with: | |
ruby-version: ${{ env.development_ruby_version }} | |
bundler-cache: true | |
- name: 🧱 Install build dependencies | |
run: make setup ${{ env.disable_rvm_proctoring }} | |
- name: 💎 Build gem | |
run: make build ${{ env.disable_rvm_proctoring }} | |
- name: 🆙 Upload dists | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
with: | |
name: Gem | |
path: ruby/pkg/collatz-*.gem | |
if-no-files-found: error | |
release: | |
name: Ruby 🔻💎🔻 Release 🚰 | |
needs: [build] | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🏁 Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: 🆒 Download dists | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
name: Gem | |
path: ruby/pkg | |
- name: 🚰 Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
export VER=$(grep lib/collatz/version.rb -e "VERSION" | cut -d \" -f 2) | |
gh release create ruby-v$VER "$(find . | grep -e pkg/collatz-*\.gem)#Gem" --generate-notes -t "Ruby: Version $VER" | |
publish: | |
name: Ruby 🔻💎🔻 Publish 📦 | |
needs: [release] | |
permissions: | |
packages: write | |
runs-on: ubuntu-latest | |
steps: | |
# Although the dists are built uses checkout to satisfy refs/tags existence | |
# which were created by the release, prior to uploading to pypi. | |
- name: 🏁 Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: 🔻💎🔻 Set up Ruby | |
uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # v1.221.0 | |
with: | |
ruby-version: ${{ env.development_ruby_version }} | |
bundler-cache: true | |
- name: 🔑 Keycutter for GitHub | |
run: make setup_github ${{ env.disable_rvm_proctoring }} | |
- name: 🆒 Download dists | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
name: Gem | |
path: ruby/pkg | |
- name: 📦 Publish to GitHub Packages | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo -e "---\n:github: Bearer $GITHUB_TOKEN" > ~/.gem/credentials | |
chmod 0600 ~/.gem/credentials | |
make push_github ${{ env.disable_rvm_proctoring }} | |
rm ~/.gem/credentials | |
- name: 📦 Publish to RubyGems | |
env: | |
RUBYGEMS_API_KEY_BASE64: ${{ secrets.RUBYGEMS_API_KEY_BASE64 }} | |
run: | | |
echo -n "$RUBYGEMS_API_KEY_BASE64" | base64 --decode > ~/.gem/credentials | |
chmod 0600 ~/.gem/credentials | |
make push_rubygems ${{ env.disable_rvm_proctoring }} | |
rm ~/.gem/credentials | |
docs: | |
name: Ruby 🔻💎🔻 Docs 📄 | |
needs: [release, publish] | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🏁 Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: 🔻💎🔻 Set up Ruby | |
uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # v1.221.0 | |
with: | |
ruby-version: ${{ env.development_ruby_version }} | |
bundler-cache: true | |
- name: 🧱 Install build dependencies | |
run: make setup ${{ env.disable_rvm_proctoring }} | |
- name: 📄 Docs Generation | |
run: make docs ${{ env.disable_rvm_proctoring }} | |
- name: 📄 Docs Publishing | |
run: | | |
git config --local user.email "actions@github.com" | |
git config --local user.name "Github Actions" | |
export SHORTSHA=$(git rev-parse --short HEAD) | |
git fetch origin gh-pages-ruby:gh-pages-ruby | |
git symbolic-ref HEAD refs/heads/gh-pages-ruby | |
cd .. && mv ruby/doc ../MERGE_TARGET | |
git rm -rf . && git clean -fxd && git reset | |
shopt -s dotglob && mkdir ruby && mv ../MERGE_TARGET/* ruby/ | |
git add . | |
git commit -m "Build based on $SHORTSHA" --allow-empty | |
git push --set-upstream origin gh-pages-ruby | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
docs-merge: | |
name: GitHub 🐱👤 Pages 📄 Merger 🧬 | |
needs: [docs] | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
uses: ./.github/workflows/github-pages.yaml | |
with: | |
merge_from: 'gh-pages-ruby' |