Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 29 additions & 48 deletions .github/workflows/build.yml → .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Publish

on:
pull_request:
Expand All @@ -8,68 +8,49 @@ on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name'
required: true

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
description: 'Tag name'
default: ''
required: false

jobs:

tests:
runs-on: cattery-gce
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.12.0
with:
mongodb-replica-set: rs0
mongodb-port: 27017

- name: run tests
run: go test -C src ./...

build:
needs: [tests]
release:
permissions:
contents: write
runs-on: cattery-gce
if: github.event.inputs.tag_name != ''
env:
VERSION: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name || github.sha }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Install dependencies
run: go mod download -C src
- name: Install dependencies
run: go mod download -C src

- name: Build
run: go build -C src -o ../bin/cattery_linux_x86_${{ env.VERSION }} -ldflags="-X cattery/cmd.Version=${{ env.VERSION }}"
- name: Build
run: go build -C src -o ../bin/cattery_linux_x86_${{ env.VERSION }} -ldflags="-X cattery/cmd.Version=${{ env.VERSION }}"

- run: ls -la bin/
- run: ls -la bin/

- name: create-release
if: github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag_name }}
name: v${{ github.event.inputs.tag_name }}
draft: true
token: ${{ github.token }}
target_commitish: ${{ github.sha }}
files: |
bin/cattery*
- name: create-release
if: github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != ''
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag_name }}
name: v${{ github.event.inputs.tag_name }}
draft: true
token: ${{ github.token }}
target_commitish: ${{ github.sha }}
files: |
bin/cattery*

docker-build:
needs: [tests]
if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'image-push')
runs-on: cattery-gce
environment: ${{ github.event_name == 'workflow_dispatch' && 'main' || null }}
Expand All @@ -95,4 +76,4 @@ jobs:
${{ env.REGISTRY_PATH }}:latest
push: true
build-args: |
CATTERY_VERSION=${{ env.VERSION }}
CATTERY_VERSION=${{ env.VERSION }}
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled]
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:

tests:
runs-on: cattery-gce
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.12.0
with:
mongodb-replica-set: rs0
mongodb-port: 27017

- name: run tests
run: go test -C src ./...