Skip to content

Add release job to CI workflow #951

Add release job to CI workflow

Add release job to CI workflow #951

Workflow file for this run

name: Continuous Integration
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: ruby_au
POSTGRES_PASSWORD: ruby_au
POSTGRES_DB: ruby_au_test
ports:
- 5432:5432
options: "--health-cmd \"pg_isready --host=localhost --username=ruby_au\" --health-interval 10s --health-timeout 5s --health-retries 5"
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: 'yarn'
- name: Install Yarn
run: npm install -g yarn@1.22.22
- name: Install Node.js dependencies
run: yarn install --frozen-lockfile
- name: Prepare assets
run: |
yarn build
bundle exec rails assets:precompile
- name: Lint Ruby code
run: bundle exec rubocop
- name: Wait for Database
run: |
until pg_isready --host=127.0.0.1 --port=5432 --username=ruby_au; do
echo "Waiting for database..."
sleep 1
done
echo "Database is ready!"
- name: Run Tests
env:
DATABASE_URL: postgres://ruby_au:ruby_au@127.0.0.1:5432/ruby_au_test
run: bundle exec rspec && bundle exec rspec sites
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}