Enhance CI Workflow for Version Bumping and Release Creation #328
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: Crystal CI | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| container: | |
| image: crystallang/crystal:1.17.1 | |
| services: | |
| # Label used to access the service container | |
| redis: | |
| # Docker Hub image | |
| image: redis | |
| # Set health checks to wait until redis has started | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Cache shards dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: lib | |
| key: ${{ runner.os }}-shards-${{ hashFiles('**/shard.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-shards- | |
| - name: Cache Crystal build artifacts | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| bin/ | |
| .crystal/ | |
| key: ${{ runner.os }}-crystal-build-${{ hashFiles('**/*.cr', '**/shard.yml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-crystal-build- | |
| - name: Cache test results | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| .crystal/ | |
| spec/ | |
| key: ${{ runner.os }}-test-cache-${{ hashFiles('**/*.cr', '**/shard.yml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-test-cache- | |
| - name: Install dependencies | |
| run: shards install | |
| - name: Build binary to test | |
| run: shards build example_app | |
| - name: Check code style | |
| run: crystal tool format --check | |
| - name: Run cache tests | |
| run: crystal spec spec/azu/cache_spec.cr --fail-fast | |
| env: | |
| CRYSTAL_ENV: pipeline | |
| CRYSTAL_LOG_SOURCES: "*" | |
| CRYSTAL_LOG_LEVEL: DEBUG | |
| PORT: 4000 | |
| PORT_REUSE: false | |
| HOST: 0.0.0.0 | |
| REDIS_HOST: redis | |
| REDIS_PORT: 6379 | |
| - name: Run handler tests | |
| run: crystal spec spec/azu/handler/ --fail-fast | |
| env: | |
| CRYSTAL_ENV: pipeline | |
| CRYSTAL_LOG_SOURCES: "*" | |
| CRYSTAL_LOG_LEVEL: DEBUG | |
| PORT: 4000 | |
| PORT_REUSE: false | |
| HOST: 0.0.0.0 | |
| REDIS_HOST: redis | |
| REDIS_PORT: 6379 | |
| - name: Run integration tests | |
| run: crystal spec spec/integration/ --fail-fast | |
| env: | |
| CRYSTAL_ENV: pipeline | |
| CRYSTAL_LOG_SOURCES: "*" | |
| CRYSTAL_LOG_LEVEL: DEBUG | |
| PORT: 4000 | |
| PORT_REUSE: false | |
| HOST: 0.0.0.0 | |
| REDIS_HOST: redis | |
| REDIS_PORT: 6379 | |
| - name: Run router and templates tests | |
| run: crystal spec spec/azu/router_spec.cr spec/azu/templates_spec.cr --fail-fast | |
| env: | |
| CRYSTAL_ENV: pipeline | |
| CRYSTAL_LOG_SOURCES: "*" | |
| CRYSTAL_LOG_LEVEL: DEBUG | |
| PORT: 4000 | |
| PORT_REUSE: false | |
| HOST: 0.0.0.0 | |
| REDIS_HOST: redis | |
| REDIS_PORT: 6379 | |
| - name: Run WebSocket and component tests | |
| run: crystal spec spec/azu/websocket_spec.cr spec/azu/channel_spec.cr spec/azu/component_spec.cr spec/azu/spark_spec.cr --fail-fast | |
| env: | |
| CRYSTAL_ENV: pipeline | |
| CRYSTAL_LOG_SOURCES: "*" | |
| CRYSTAL_LOG_LEVEL: DEBUG | |
| PORT: 4000 | |
| PORT_REUSE: false | |
| HOST: 0.0.0.0 | |
| REDIS_HOST: redis | |
| REDIS_PORT: 6379 | |
| # - name: Run core framework tests | |
| # run: crystal spec spec/azu/configuration_spec.cr spec/azu/endpoint_spec.cr spec/azu/environment_spec.cr spec/azu/error_spec.cr spec/azu/http_request_spec.cr spec/azu/log_format_spec.cr spec/azu/markup_spec.cr spec/azu/method_spec.cr spec/azu/params_spec.cr spec/azu/request_spec.cr spec/azu/response_spec.cr --fail-fast | |
| # env: | |
| # CRYSTAL_ENV: pipeline | |
| # CRYSTAL_LOG_SOURCES: "*" | |
| # CRYSTAL_LOG_LEVEL: DEBUG | |
| # PORT: 4000 | |
| # PORT_REUSE: false | |
| # HOST: 0.0.0.0 | |
| # REDIS_HOST: redis | |
| # REDIS_PORT: 6379 | |
| # - name: Run remaining core tests | |
| # run: crystal spec spec/azu/content_negotiator_spec.cr spec/azu/csrf_spec.cr spec/azu/file_upload_spec.cr spec/azu/performance_monitoring_spec.cr spec/azu/performance_reporter_spec.cr spec/azu/refactoring_spec.cr --fail-fast | |
| # env: | |
| # CRYSTAL_ENV: pipeline | |
| # CRYSTAL_LOG_SOURCES: "*" | |
| # CRYSTAL_LOG_LEVEL: DEBUG | |
| # PORT: 4000 | |
| # PORT_REUSE: false | |
| # HOST: 0.0.0.0 | |
| # REDIS_HOST: redis | |
| # REDIS_PORT: 6379 | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - test | |
| if: ${{ success() }} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Compute Release Version | |
| id: semver | |
| uses: paulhatch/[email protected] | |
| with: | |
| tag_prefix: "v" | |
| major_pattern: "(MAJOR)" | |
| minor_pattern: "(MINOR)" | |
| version_format: "${major}.${minor}.${patch}" | |
| bump_each_commit: false | |
| search_commit_body: true | |
| user_format_type: "csv" | |
| - name: Configure git identity | |
| run: | | |
| git config user.name "eliasjpr" | |
| git config user.email "[email protected]" | |
| - name: Bump Shard Version | |
| id: bump-shard | |
| uses: fjogeleit/yaml-update-action@master | |
| with: | |
| valueFile: shard.yml | |
| propertyPath: version | |
| value: ${{steps.semver.outputs.version}} | |
| commitChange: true | |
| targetBranch: master | |
| masterBranchName: master | |
| createPR: false | |
| branch: master | |
| message: Set shard version ${{ steps.semver.outputs.version }} | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{steps.semver.outputs.version_tag}} | |
| release_name: Release v${{steps.semver.outputs.version}} | |
| draft: false | |
| prerelease: false |