Skip to content

Use gh cli for creating releases. #31

Use gh cli for creating releases.

Use gh cli for creating releases. #31

name: Build & Release
on:
workflow_dispatch:
push:
branches: [ main ]
release:
types: [published]
pull_request:
branches: [ main ]
env:
GO_VERSION: 1.19.8
RUBY_VERSION: 3.1.2
BUNDLER_VERSION: 2.3.7
jobs:
build:
if: |
!contains(github.event.pull_request.labels.*.name, 'skip:ci')
name: "build"
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/omnibus/Gemfile
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler: ${{ env.BUNDLER_VERSION}}
bundler-cache: true
- name: Unit test
run: |
sudo mkdir -p /opt/gemfast/etc/gemfast/
sudo chown -R $USER: /opt/gemfast
make test
- name: Get version
id: get-version
run: |
v=$(cat VERSION)
echo "version=${v}" >> "$GITHUB_OUTPUT"
- name: Build omnibus package
run: |
sudo mkdir -p /var/cache/omnibus
sudo chown -R $USER: /var/cache/omnibus
cd omnibus
bundle exec omnibus build gemfast
sha512sum pkg/*.deb > "pkg/gemfast_${{ steps.get-version.outputs.VERSION }}-pre_checksums.txt"
- name: Upload omnibus package
uses: actions/upload-artifact@v3
with:
name: gemfast-omnibus
path: omnibus/pkg/
if-no-files-found: error
- name: Build docker image
run: |
docker build -t server:${{ steps.get-version.outputs.VERSION }}-pre .
docker tag server:${{ steps.get-version.outputs.VERSION }}-pre server:latest
docker save server:latest > gemfast-${{ steps.get-version.outputs.VERSION }}-pre.tar
- name: Upload docker image
uses: actions/upload-artifact@v3
with:
name: gemfast-docker
path: gemfast-${{ steps.get-version.outputs.VERSION }}-pre.tar
if-no-files-found: error
smoke-test:
name: "smoke"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
pkg: [omnibus, docker]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: rails/rails
path: clones/rails
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- uses: actions/download-artifact@v3
with:
name: gemfast-${{ matrix.pkg }}
- name: Smoke test
run: ./scripts/run_smoke_tests.sh "${{ matrix.pkg }}"
env:
BUILD_TYPE: "${{ matrix.pkg }}"
cve-test:
name: "cve"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
pkg: [omnibus, docker]
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- uses: actions/download-artifact@v3
with:
name: gemfast-${{ matrix.pkg }}
- name: CVE test
run: ./scripts/run_cve_tests.sh "${{ matrix.pkg }}"
env:
BUILD_TYPE: "${{ matrix.pkg }}"
filter-test:
name: "filter"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
pkg: [omnibus, docker]
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- uses: actions/download-artifact@v3
with:
name: gemfast-${{ matrix.pkg }}
- name: Filter test
run: ./scripts/run_filter_tests.sh "${{ matrix.pkg }}"
env:
BUILD_TYPE: "${{ matrix.pkg }}"
private-gems-test:
name: "private-gems"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
pkg: [omnibus, docker]
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- uses: actions/download-artifact@v3
with:
name: gemfast-${{ matrix.pkg }}
- name: Private gems test
run: ./scripts/run_private_gem_tests.sh "${{ matrix.pkg }}"
env:
BUILD_TYPE: "${{ matrix.pkg }}"
auth-test:
name: "auth"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
pkg: [omnibus, docker]
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- uses: actions/download-artifact@v3
with:
name: gemfast-${{ matrix.pkg }}
- name: Private gems test
run: ./scripts/run_auth_tests.sh
env:
BUILD_TYPE: "${{ matrix.pkg }}"
pre-release:
name: "pre-release"
permissions: write-all
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: "ubuntu-latest"
needs:
- build
- smoke-test
- cve-test
- filter-test
- private-gems-test
- auth-test
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/download-artifact@v3
with:
name: gemfast-omnibus
- uses: actions/download-artifact@v3
with:
name: gemfast-docker
- name: Get version
id: get-version
run: |
v=$(cat VERSION)
echo "version=${v}" >> "$GITHUB_OUTPUT"
- name: Rename omnibus artifact
run: |
mv *.deb "gemfast-${{ steps.get-version.outputs.VERSION }}-pre-amd64.deb"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push docker image
run: |
docker load < gemfast-${{ steps.get-version.outputs.VERSION }}-pre.tar
docker tag server:latest ghcr.io/gemfast/server:${{ steps.get-version.outputs.VERSION }}-pre
docker push ghcr.io/gemfast/server:${{ steps.get-version.outputs.VERSION }}-pre
- name: Create pre-release
run: |
gh release create --latest --generate-notes --title "${{ steps.get-version.outputs.VERSION }} Pre-Release" --prerelease \
"gemfast-${{ steps.get-version.outputs.VERSION }}-amd64.deb" \
"gemfast-${{ steps.get-version.outputs.VERSION }}_checksums.txt"
tagged-release:
if: startsWith(github.ref, 'refs/tags/v')
name: "release"
permissions: write-all
runs-on: "ubuntu-latest"
needs:
- build
- smoke-test
- cve-test
- filter-test
- private-gems-test
- auth-test
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/download-artifact@v3
with:
name: gemfast-omnibus
- uses: actions/download-artifact@v3
with:
name: gemfast-docker
- name: Get version
id: get-version
run: |
v=$(cat VERSION)
echo "version=${v}" >> "$GITHUB_OUTPUT"
- name: Rename omnibus artifact
run: |
mv *.deb "gemfast-${{ steps.get-version.outputs.VERSION }}-amd64.deb"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push docker image
run: |
docker load < gemfast-${{ steps.get-version.outputs.VERSION }}-pre.tar
docker tag server:latest ghcr.io/gemfast/server:${{ steps.get-version.outputs.VERSION }}
docker push ghcr.io/gemfast/server:${{ steps.get-version.outputs.VERSION }}
docker tag ghcr.io/gemfast/server:${{ steps.get-version.outputs.VERSION }} ghcr.io/gemfast/server:latest
docker push ghcr.io/gemfast/server:latest
- name: Create release
run: |
gh release create --latest --generate-notes --title "${{ steps.get-version.outputs.VERSION }}" \
"gemfast-${{ steps.get-version.outputs.VERSION }}-amd64.deb" \
"gemfast-${{ steps.get-version.outputs.VERSION }}_checksums.txt"
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
title: "${{ steps.get-version.outputs.VERSION }}"
files: |
*.deb
*.txt
cleanup:
runs-on: ubuntu-latest
needs:
- build
- smoke-test
- cve-test
- filter-test
- private-gems-test
- auth-test
- pre-release
- tagged-release
if: ${{ always() && !cancelled() && needs.build.result == 'success' }}
steps:
- uses: geekyeggo/delete-artifact@v2
with:
name: gemfast-${{ matrix.pkg }}