Cybersecurity-Projects/.github/workflows/publish-marshalsea.yml

99 lines
3.2 KiB
YAML

# =============================================================================
# AngelaMos | 2026
# publish-marshalsea.yml
# =============================================================================
name: Publish marshalsea to RubyGems
on:
push:
tags:
- 'marshalsea-v*'
workflow_dispatch:
permissions:
contents: read
env:
PROJECT_DIR: PROJECTS/beginner/deserialization-gadget-lab
jobs:
test:
name: Test on Ruby ${{ matrix.ruby }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
ruby: ['3.4', '4.0']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
working-directory: PROJECTS/beginner/deserialization-gadget-lab
- name: Run the suites
working-directory: PROJECTS/beginner/deserialization-gadget-lab
run: |
for suite in test/marshal/parser_test.rb test/scanner_test.rb test/chains_test.rb \
test/marshal/boundary_detector_test.rb test/corpus_test.rb; do
echo "::group::${suite}"
ruby -Ilib -Itest "${suite}"
echo "::endgroup::"
done
- name: Run the standalone controls
working-directory: PROJECTS/beginner/deserialization-gadget-lab
run: ruby -Ilib -Itest test/control_check.rb
- name: Confirm the declared floor matches this matrix
working-directory: PROJECTS/beginner/deserialization-gadget-lab
run: |
floor=$(ruby -e 'print Gem::Specification.load("marshalsea.gemspec").required_ruby_version.to_s')
echo "gemspec declares ${floor}, tested on ${{ matrix.ruby }}"
test "${floor}" = ">= 3.4" || {
echo "::error::gemspec floor ${floor} no longer matches the tested matrix"
exit 1
}
release:
name: Push marshalsea to RubyGems
needs: test
runs-on: ubuntu-latest
environment:
name: rubygems
url: https://rubygems.org/gems/marshalsea
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0'
bundler-cache: true
working-directory: PROJECTS/beginner/deserialization-gadget-lab
- name: Confirm the tag matches the gem version
working-directory: PROJECTS/beginner/deserialization-gadget-lab
run: |
version=$(ruby -e 'require "./lib/marshalsea/version"; print Marshalsea::VERSION')
expected="marshalsea-v${version}"
echo "tag=${GITHUB_REF_NAME} gemspec=${expected}"
if [ "${GITHUB_REF_NAME}" != "${expected}" ] && [ "${GITHUB_EVENT_NAME}" = "push" ]; then
echo "::error::tag ${GITHUB_REF_NAME} does not match ${expected}"
exit 1
fi
- name: Release to RubyGems with trusted publishing and attestation
uses: rubygems/release-gem@v1
with:
working-directory: PROJECTS/beginner/deserialization-gadget-lab