mirror of
https://github.com/databasus/databasus.git
synced 2026-04-06 00:32:03 +02:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df0f7e0e7a | ||
|
|
6418de87db | ||
|
|
230f66bb10 | ||
|
|
1cd10772ae | ||
|
|
d56518b847 | ||
|
|
64195024c6 | ||
|
|
200429dbab | ||
|
|
07ad7d9a2a |
453
.github/workflows/ci-release.yml
vendored
Normal file
453
.github/workflows/ci-release.yml
vendored
Normal file
@@ -0,0 +1,453 @@
|
||||
name: CI and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
lint-backend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.23.3"
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Install golangci-lint
|
||||
run: |
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.3
|
||||
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Install swag for swagger generation
|
||||
run: go install github.com/swaggo/swag/cmd/swag@v1.16.4
|
||||
|
||||
- name: Generate swagger docs
|
||||
run: |
|
||||
cd backend
|
||||
swag init -d . -g cmd/main.go -o swagger
|
||||
|
||||
- name: Run golangci-lint
|
||||
run: |
|
||||
cd backend
|
||||
golangci-lint run
|
||||
|
||||
- name: Verify go mod tidy
|
||||
run: |
|
||||
cd backend
|
||||
go mod tidy
|
||||
git diff --exit-code go.mod go.sum || (echo "go mod tidy made changes, please run 'go mod tidy' and commit the changes" && exit 1)
|
||||
|
||||
lint-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
cache: "npm"
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm ci
|
||||
|
||||
- name: Check if prettier was run
|
||||
run: |
|
||||
cd frontend
|
||||
npm run format
|
||||
git diff --exit-code || (echo "Prettier made changes, please run 'npm run format' and commit the changes" && exit 1)
|
||||
|
||||
- name: Check if linter was run
|
||||
run: |
|
||||
cd frontend
|
||||
npm run lint
|
||||
|
||||
test-backend:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint-backend]
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.23.3"
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Create .env file for testing
|
||||
run: |
|
||||
cd backend
|
||||
cat > .env << EOF
|
||||
# docker-compose.yml
|
||||
DEV_DB_NAME=postgresus
|
||||
DEV_DB_USERNAME=postgres
|
||||
DEV_DB_PASSWORD=Q1234567
|
||||
#app
|
||||
ENV_MODE=development
|
||||
# db
|
||||
DATABASE_DSN=host=localhost user=postgres password=Q1234567 dbname=postgresus port=5437 sslmode=disable
|
||||
DATABASE_URL=postgres://postgres:Q1234567@localhost:5437/postgresus?sslmode=disable
|
||||
# migrations
|
||||
GOOSE_DRIVER=postgres
|
||||
GOOSE_DBSTRING=postgres://postgres:Q1234567@localhost:5437/postgresus?sslmode=disable
|
||||
GOOSE_MIGRATION_DIR=./migrations
|
||||
# testing
|
||||
# to get Google Drive env variables: add storage in UI and copy data from added storage here
|
||||
TEST_GOOGLE_DRIVE_CLIENT_ID=${{ secrets.TEST_GOOGLE_DRIVE_CLIENT_ID }}
|
||||
TEST_GOOGLE_DRIVE_CLIENT_SECRET=${{ secrets.TEST_GOOGLE_DRIVE_CLIENT_SECRET }}
|
||||
TEST_GOOGLE_DRIVE_TOKEN_JSON=${{ secrets.TEST_GOOGLE_DRIVE_TOKEN_JSON }}
|
||||
# testing DBs
|
||||
TEST_POSTGRES_13_PORT=5001
|
||||
TEST_POSTGRES_14_PORT=5002
|
||||
TEST_POSTGRES_15_PORT=5003
|
||||
TEST_POSTGRES_16_PORT=5004
|
||||
TEST_POSTGRES_17_PORT=5005
|
||||
# testing S3
|
||||
TEST_MINIO_PORT=9000
|
||||
TEST_MINIO_CONSOLE_PORT=9001
|
||||
EOF
|
||||
|
||||
- name: Start test containers
|
||||
run: |
|
||||
cd backend
|
||||
docker compose -f docker-compose.yml.example up -d
|
||||
|
||||
- name: Wait for containers to be ready
|
||||
run: |
|
||||
# Wait for main dev database
|
||||
timeout 60 bash -c 'until docker exec dev-db pg_isready -h localhost -p 5437 -U postgres; do sleep 2; done'
|
||||
|
||||
# Wait for test databases
|
||||
timeout 60 bash -c 'until nc -z localhost 5001; do sleep 2; done'
|
||||
timeout 60 bash -c 'until nc -z localhost 5002; do sleep 2; done'
|
||||
timeout 60 bash -c 'until nc -z localhost 5003; do sleep 2; done'
|
||||
timeout 60 bash -c 'until nc -z localhost 5004; do sleep 2; done'
|
||||
timeout 60 bash -c 'until nc -z localhost 5005; do sleep 2; done'
|
||||
|
||||
# Wait for MinIO
|
||||
timeout 60 bash -c 'until nc -z localhost 9000; do sleep 2; done'
|
||||
|
||||
- name: Install PostgreSQL client tools
|
||||
run: |
|
||||
chmod +x backend/tools/download_linux.sh
|
||||
cd backend/tools
|
||||
./download_linux.sh
|
||||
|
||||
- name: Run database migrations
|
||||
run: |
|
||||
cd backend
|
||||
go install github.com/pressly/goose/v3/cmd/goose@latest
|
||||
goose up
|
||||
|
||||
- name: Run Go tests
|
||||
run: |
|
||||
cd backend
|
||||
go test ./internal/...
|
||||
|
||||
- name: Stop test containers
|
||||
if: always()
|
||||
run: |
|
||||
cd backend
|
||||
docker compose -f docker-compose.yml.example down -v
|
||||
|
||||
determine-version:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test-backend, lint-frontend]
|
||||
if: ${{ github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[skip-release]') }}
|
||||
outputs:
|
||||
should_release: ${{ steps.version_bump.outputs.should_release }}
|
||||
new_version: ${{ steps.version_bump.outputs.new_version }}
|
||||
bump_type: ${{ steps.version_bump.outputs.bump_type }}
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
|
||||
- name: Install semver
|
||||
run: npm install -g semver
|
||||
|
||||
- name: Get current version
|
||||
id: current_version
|
||||
run: |
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
echo "current_version=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
|
||||
echo "Current version: ${LATEST_TAG#v}"
|
||||
|
||||
- name: Analyze commits and determine version bump
|
||||
id: version_bump
|
||||
run: |
|
||||
CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}"
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
|
||||
# Get commits since last tag
|
||||
if [ "$LATEST_TAG" = "v0.0.0" ]; then
|
||||
COMMITS=$(git log --pretty=format:"%s" --no-merges)
|
||||
else
|
||||
COMMITS=$(git log ${LATEST_TAG}..HEAD --pretty=format:"%s" --no-merges)
|
||||
fi
|
||||
|
||||
echo "Analyzing commits:"
|
||||
echo "$COMMITS"
|
||||
|
||||
# Initialize flags
|
||||
HAS_FEATURE=false
|
||||
HAS_FIX=false
|
||||
HAS_BREAKING=false
|
||||
|
||||
# Analyze each commit
|
||||
while IFS= read -r commit; do
|
||||
if [[ "$commit" =~ ^FEATURE ]]; then
|
||||
HAS_FEATURE=true
|
||||
echo "Found FEATURE commit: $commit"
|
||||
elif [[ "$commit" =~ ^FIX ]]; then
|
||||
HAS_FIX=true
|
||||
echo "Found FIX commit: $commit"
|
||||
elif [[ "$commit" =~ ^REFACTOR ]]; then
|
||||
HAS_FIX=true # Treat refactor as patch
|
||||
echo "Found REFACTOR commit: $commit"
|
||||
fi
|
||||
|
||||
# Check for breaking changes
|
||||
if [[ "$commit" =~ BREAKING[[:space:]]CHANGE ]] || [[ "$commit" =~ "!" ]]; then
|
||||
HAS_BREAKING=true
|
||||
echo "Found BREAKING CHANGE: $commit"
|
||||
fi
|
||||
done <<< "$COMMITS"
|
||||
|
||||
# Determine version bump
|
||||
if [ "$HAS_BREAKING" = true ]; then
|
||||
BUMP_TYPE="major"
|
||||
elif [ "$HAS_FEATURE" = true ]; then
|
||||
BUMP_TYPE="minor"
|
||||
elif [ "$HAS_FIX" = true ]; then
|
||||
BUMP_TYPE="patch"
|
||||
else
|
||||
BUMP_TYPE="none"
|
||||
fi
|
||||
|
||||
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
|
||||
|
||||
if [ "$BUMP_TYPE" != "none" ]; then
|
||||
NEW_VERSION=$(npx semver -i $BUMP_TYPE $CURRENT_VERSION)
|
||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "should_release=true" >> $GITHUB_OUTPUT
|
||||
echo "New version will be: $NEW_VERSION"
|
||||
else
|
||||
echo "should_release=false" >> $GITHUB_OUTPUT
|
||||
echo "No version bump needed"
|
||||
fi
|
||||
|
||||
build-only:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test-backend, lint-frontend]
|
||||
if: ${{ github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[skip-release]') }}
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU (enables multi-arch emulation)
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push SHA-only tags
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: |
|
||||
rostislavdugin/postgresus:latest
|
||||
rostislavdugin/postgresus:${{ github.sha }}
|
||||
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [determine-version]
|
||||
if: ${{ needs.determine-version.outputs.should_release == 'true' }}
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU (enables multi-arch emulation)
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push with version tags
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: |
|
||||
rostislavdugin/postgresus:latest
|
||||
rostislavdugin/postgresus:v${{ needs.determine-version.outputs.new_version }}
|
||||
rostislavdugin/postgresus:${{ github.sha }}
|
||||
|
||||
- name: Update Docker Hub description
|
||||
uses: peter-evans/dockerhub-description@v4
|
||||
continue-on-error: true
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
repository: rostislavdugin/postgresus
|
||||
short-description: "Free PostgreSQL monitoring & backup solution with multi-storage support"
|
||||
readme-filepath: ./README.md
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [determine-version, build-and-push]
|
||||
if: ${{ needs.determine-version.outputs.should_release == 'true' }}
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
run: |
|
||||
NEW_VERSION="${{ needs.determine-version.outputs.new_version }}"
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
|
||||
# Get commits since last tag
|
||||
if [ "$LATEST_TAG" = "v0.0.0" ]; then
|
||||
COMMITS=$(git log --pretty=format:"%s|%H|%an|%ad" --date=short --no-merges)
|
||||
else
|
||||
COMMITS=$(git log ${LATEST_TAG}..HEAD --pretty=format:"%s|%H|%an|%ad" --date=short --no-merges)
|
||||
fi
|
||||
|
||||
# Create changelog
|
||||
CHANGELOG="# Changelog\n\n## [${NEW_VERSION}] - $(date +%Y-%m-%d)\n\n"
|
||||
|
||||
# Group commits by type and area
|
||||
FEATURES=""
|
||||
FIXES=""
|
||||
REFACTORS=""
|
||||
|
||||
while IFS= read -r line; do
|
||||
if [ -n "$line" ]; then
|
||||
COMMIT_MSG=$(echo "$line" | cut -d'|' -f1)
|
||||
COMMIT_HASH=$(echo "$line" | cut -d'|' -f2)
|
||||
SHORT_HASH=${COMMIT_HASH:0:7}
|
||||
|
||||
# Parse commit message format: TYPE (area): description
|
||||
if [[ "$COMMIT_MSG" == FEATURE* ]]; then
|
||||
TEMP="${COMMIT_MSG#FEATURE}"
|
||||
TEMP="${TEMP#"${TEMP%%[![:space:]]*}"}"
|
||||
if [[ "$TEMP" == \(* ]]; then
|
||||
AREA=$(echo "$TEMP" | sed 's/^(\([^)]*\)).*/\1/')
|
||||
DESC=$(echo "$TEMP" | sed 's/^([^)]*):[[:space:]]*//')
|
||||
FEATURES="${FEATURES}- **${AREA}**: ${DESC} ([${SHORT_HASH}](https://github.com/${{ github.repository }}/commit/${COMMIT_HASH}))\n"
|
||||
fi
|
||||
elif [[ "$COMMIT_MSG" == FIX* ]]; then
|
||||
TEMP="${COMMIT_MSG#FIX}"
|
||||
TEMP="${TEMP#"${TEMP%%[![:space:]]*}"}"
|
||||
if [[ "$TEMP" == \(* ]]; then
|
||||
AREA=$(echo "$TEMP" | sed 's/^(\([^)]*\)).*/\1/')
|
||||
DESC=$(echo "$TEMP" | sed 's/^([^)]*):[[:space:]]*//')
|
||||
FIXES="${FIXES}- **${AREA}**: ${DESC} ([${SHORT_HASH}](https://github.com/${{ github.repository }}/commit/${COMMIT_HASH}))\n"
|
||||
fi
|
||||
elif [[ "$COMMIT_MSG" == REFACTOR* ]]; then
|
||||
TEMP="${COMMIT_MSG#REFACTOR}"
|
||||
TEMP="${TEMP#"${TEMP%%[![:space:]]*}"}"
|
||||
if [[ "$TEMP" == \(* ]]; then
|
||||
AREA=$(echo "$TEMP" | sed 's/^(\([^)]*\)).*/\1/')
|
||||
DESC=$(echo "$TEMP" | sed 's/^([^)]*):[[:space:]]*//')
|
||||
REFACTORS="${REFACTORS}- **${AREA}**: ${DESC} ([${SHORT_HASH}](https://github.com/${{ github.repository }}/commit/${COMMIT_HASH}))\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done <<< "$COMMITS"
|
||||
|
||||
# Build changelog sections
|
||||
if [ -n "$FEATURES" ]; then
|
||||
CHANGELOG="${CHANGELOG}### ✨ Features\n${FEATURES}\n"
|
||||
fi
|
||||
|
||||
if [ -n "$FIXES" ]; then
|
||||
CHANGELOG="${CHANGELOG}### 🐛 Bug Fixes\n${FIXES}\n"
|
||||
fi
|
||||
|
||||
if [ -n "$REFACTORS" ]; then
|
||||
CHANGELOG="${CHANGELOG}### 🔨 Refactoring\n${REFACTORS}\n"
|
||||
fi
|
||||
|
||||
# Add Docker image info
|
||||
CHANGELOG="${CHANGELOG}### 🐳 Docker\n"
|
||||
CHANGELOG="${CHANGELOG}- **Image**: \`rostislavdugin/postgresus:v${NEW_VERSION}\`\n"
|
||||
CHANGELOG="${CHANGELOG}- **Platforms**: linux/amd64, linux/arm64\n\n"
|
||||
|
||||
# Set output for GitHub release
|
||||
{
|
||||
echo 'changelog<<EOF'
|
||||
echo -e "$CHANGELOG"
|
||||
echo EOF
|
||||
} >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: v${{ needs.determine-version.outputs.new_version }}
|
||||
release_name: Release v${{ needs.determine-version.outputs.new_version }}
|
||||
body: ${{ steps.changelog.outputs.changelog }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
121
.github/workflows/docker.yml
vendored
121
.github/workflows/docker.yml
vendored
@@ -1,121 +0,0 @@
|
||||
name: Build & push Docker image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
lint-backend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.23.3"
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/go/pkg/mod
|
||||
~/.cache/go-build
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: Install golangci-lint
|
||||
run: |
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.3
|
||||
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Install swag for swagger generation
|
||||
run: go install github.com/swaggo/swag/cmd/swag@v1.16.4
|
||||
|
||||
- name: Generate swagger docs
|
||||
run: |
|
||||
cd backend
|
||||
swag init -d . -g cmd/main.go -o swagger
|
||||
|
||||
- name: Run golangci-lint
|
||||
run: |
|
||||
cd backend
|
||||
golangci-lint run
|
||||
|
||||
- name: Verify go mod tidy
|
||||
run: |
|
||||
cd backend
|
||||
go mod tidy
|
||||
git diff --exit-code go.mod go.sum || (echo "go mod tidy made changes, please run 'go mod tidy' and commit the changes" && exit 1)
|
||||
|
||||
lint-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
cache: "npm"
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd frontend
|
||||
npm ci
|
||||
|
||||
- name: Check if prettier was run
|
||||
run: |
|
||||
cd frontend
|
||||
npm run format
|
||||
git diff --exit-code || (echo "Prettier made changes, please run 'npm run format' and commit the changes" && exit 1)
|
||||
|
||||
- name: Check if linter was run
|
||||
run: |
|
||||
cd frontend
|
||||
npm run lint
|
||||
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint-backend, lint-frontend]
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU (enables multi-arch emulation)
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64 # both chip families
|
||||
tags: |
|
||||
rostislavdugin/postgresus:latest
|
||||
rostislavdugin/postgresus:${{ github.sha }}
|
||||
|
||||
- name: Update Docker Hub description
|
||||
uses: peter-evans/dockerhub-description@v4
|
||||
continue-on-error: true
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
repository: rostislavdugin/postgresus
|
||||
short-description: "Free PostgreSQL monitoring & backup solution"
|
||||
readme-filepath: ./README.md
|
||||
235
.github/workflows/release.yml
vendored
235
.github/workflows/release.yml
vendored
@@ -1,235 +0,0 @@
|
||||
name: Automated Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ !contains(github.event.head_commit.message, '[skip-release]') }}
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
npm install -g conventional-changelog-cli
|
||||
npm install -g semver
|
||||
|
||||
- name: Get current version
|
||||
id: current_version
|
||||
run: |
|
||||
# Get the latest tag, default to 0.0.0 if no tags exist
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
echo "current_version=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
|
||||
echo "Current version: ${LATEST_TAG#v}"
|
||||
|
||||
- name: Analyze commits and determine version bump
|
||||
id: version_bump
|
||||
run: |
|
||||
CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}"
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
|
||||
# Get commits since last tag
|
||||
if [ "$LATEST_TAG" = "v0.0.0" ]; then
|
||||
COMMITS=$(git log --pretty=format:"%s" --no-merges)
|
||||
else
|
||||
COMMITS=$(git log ${LATEST_TAG}..HEAD --pretty=format:"%s" --no-merges)
|
||||
fi
|
||||
|
||||
echo "Analyzing commits:"
|
||||
echo "$COMMITS"
|
||||
|
||||
# Initialize flags
|
||||
HAS_FEATURE=false
|
||||
HAS_FIX=false
|
||||
HAS_BREAKING=false
|
||||
|
||||
# Analyze each commit
|
||||
while IFS= read -r commit; do
|
||||
if [[ "$commit" =~ ^FEATURE ]]; then
|
||||
HAS_FEATURE=true
|
||||
echo "Found FEATURE commit: $commit"
|
||||
elif [[ "$commit" =~ ^FIX ]]; then
|
||||
HAS_FIX=true
|
||||
echo "Found FIX commit: $commit"
|
||||
elif [[ "$commit" =~ ^REFACTOR ]]; then
|
||||
HAS_FIX=true # Treat refactor as patch
|
||||
echo "Found REFACTOR commit: $commit"
|
||||
fi
|
||||
|
||||
# Check for breaking changes
|
||||
if [[ "$commit" =~ BREAKING[[:space:]]CHANGE ]] || [[ "$commit" =~ "!" ]]; then
|
||||
HAS_BREAKING=true
|
||||
echo "Found BREAKING CHANGE: $commit"
|
||||
fi
|
||||
done <<< "$COMMITS"
|
||||
|
||||
# Determine version bump
|
||||
if [ "$HAS_BREAKING" = true ]; then
|
||||
BUMP_TYPE="major"
|
||||
elif [ "$HAS_FEATURE" = true ]; then
|
||||
BUMP_TYPE="minor"
|
||||
elif [ "$HAS_FIX" = true ]; then
|
||||
BUMP_TYPE="patch"
|
||||
else
|
||||
BUMP_TYPE="none"
|
||||
fi
|
||||
|
||||
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
|
||||
|
||||
if [ "$BUMP_TYPE" != "none" ]; then
|
||||
NEW_VERSION=$(npx semver -i $BUMP_TYPE $CURRENT_VERSION)
|
||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "should_release=true" >> $GITHUB_OUTPUT
|
||||
echo "New version will be: $NEW_VERSION"
|
||||
else
|
||||
echo "should_release=false" >> $GITHUB_OUTPUT
|
||||
echo "No version bump needed"
|
||||
fi
|
||||
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
if: steps.version_bump.outputs.should_release == 'true'
|
||||
run: |
|
||||
CURRENT_VERSION="${{ steps.current_version.outputs.current_version }}"
|
||||
NEW_VERSION="${{ steps.version_bump.outputs.new_version }}"
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
|
||||
# Get commits since last tag
|
||||
if [ "$LATEST_TAG" = "v0.0.0" ]; then
|
||||
COMMITS=$(git log --pretty=format:"%s|%H|%an|%ad" --date=short --no-merges)
|
||||
else
|
||||
COMMITS=$(git log ${LATEST_TAG}..HEAD --pretty=format:"%s|%H|%an|%ad" --date=short --no-merges)
|
||||
fi
|
||||
|
||||
# Create changelog
|
||||
CHANGELOG="# Changelog\n\n## [${NEW_VERSION}] - $(date +%Y-%m-%d)\n\n"
|
||||
|
||||
# Group commits by type and area
|
||||
FEATURES=""
|
||||
FIXES=""
|
||||
REFACTORS=""
|
||||
|
||||
while IFS= read -r line; do
|
||||
if [ -n "$line" ]; then
|
||||
COMMIT_MSG=$(echo "$line" | cut -d'|' -f1)
|
||||
COMMIT_HASH=$(echo "$line" | cut -d'|' -f2)
|
||||
COMMIT_AUTHOR=$(echo "$line" | cut -d'|' -f3)
|
||||
COMMIT_DATE=$(echo "$line" | cut -d'|' -f4)
|
||||
SHORT_HASH=${COMMIT_HASH:0:7}
|
||||
|
||||
# Parse commit message format: TYPE (area): description
|
||||
if [[ "$COMMIT_MSG" == FEATURE* ]]; then
|
||||
# Extract area and description
|
||||
TEMP="${COMMIT_MSG#FEATURE}"
|
||||
TEMP="${TEMP#"${TEMP%%[![:space:]]*}"}" # trim leading spaces
|
||||
if [[ "$TEMP" == \(* ]]; then
|
||||
AREA=$(echo "$TEMP" | sed 's/^(\([^)]*\)).*/\1/')
|
||||
DESC=$(echo "$TEMP" | sed 's/^([^)]*):[[:space:]]*//')
|
||||
FEATURES="${FEATURES}- **${AREA}**: ${DESC} ([${SHORT_HASH}](https://github.com/${{ github.repository }}/commit/${COMMIT_HASH}))\n"
|
||||
fi
|
||||
elif [[ "$COMMIT_MSG" == FIX* ]]; then
|
||||
# Extract area and description
|
||||
TEMP="${COMMIT_MSG#FIX}"
|
||||
TEMP="${TEMP#"${TEMP%%[![:space:]]*}"}" # trim leading spaces
|
||||
if [[ "$TEMP" == \(* ]]; then
|
||||
AREA=$(echo "$TEMP" | sed 's/^(\([^)]*\)).*/\1/')
|
||||
DESC=$(echo "$TEMP" | sed 's/^([^)]*):[[:space:]]*//')
|
||||
FIXES="${FIXES}- **${AREA}**: ${DESC} ([${SHORT_HASH}](https://github.com/${{ github.repository }}/commit/${COMMIT_HASH}))\n"
|
||||
fi
|
||||
elif [[ "$COMMIT_MSG" == REFACTOR* ]]; then
|
||||
# Extract area and description
|
||||
TEMP="${COMMIT_MSG#REFACTOR}"
|
||||
TEMP="${TEMP#"${TEMP%%[![:space:]]*}"}" # trim leading spaces
|
||||
if [[ "$TEMP" == \(* ]]; then
|
||||
AREA=$(echo "$TEMP" | sed 's/^(\([^)]*\)).*/\1/')
|
||||
DESC=$(echo "$TEMP" | sed 's/^([^)]*):[[:space:]]*//')
|
||||
REFACTORS="${REFACTORS}- **${AREA}**: ${DESC} ([${SHORT_HASH}](https://github.com/${{ github.repository }}/commit/${COMMIT_HASH}))\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done <<< "$COMMITS"
|
||||
|
||||
# Build changelog sections
|
||||
if [ -n "$FEATURES" ]; then
|
||||
CHANGELOG="${CHANGELOG}### ✨ Features\n${FEATURES}\n"
|
||||
fi
|
||||
|
||||
if [ -n "$FIXES" ]; then
|
||||
CHANGELOG="${CHANGELOG}### 🐛 Bug Fixes\n${FIXES}\n"
|
||||
fi
|
||||
|
||||
if [ -n "$REFACTORS" ]; then
|
||||
CHANGELOG="${CHANGELOG}### 🔨 Refactoring\n${REFACTORS}\n"
|
||||
fi
|
||||
|
||||
# Save changelog to file
|
||||
echo -e "$CHANGELOG" > RELEASE_CHANGELOG.md
|
||||
|
||||
# Update main CHANGELOG.md - preserve all version history
|
||||
if [ -f "CHANGELOG.md" ]; then
|
||||
# Get the header until [Unreleased] section
|
||||
sed -n '1,/## \[Unreleased\]/p' CHANGELOG.md > NEW_CHANGELOG.md
|
||||
echo "" >> NEW_CHANGELOG.md
|
||||
# Add the new release (without the "# Changelog" header)
|
||||
echo "## [${NEW_VERSION}] - $(date +%Y-%m-%d)" >> NEW_CHANGELOG.md
|
||||
echo "" >> NEW_CHANGELOG.md
|
||||
|
||||
# Add the new release sections
|
||||
if [ -n "$FEATURES" ]; then
|
||||
echo "### ✨ Features" >> NEW_CHANGELOG.md
|
||||
echo -e "$FEATURES" >> NEW_CHANGELOG.md
|
||||
fi
|
||||
|
||||
if [ -n "$FIXES" ]; then
|
||||
echo "### 🐛 Bug Fixes" >> NEW_CHANGELOG.md
|
||||
echo -e "$FIXES" >> NEW_CHANGELOG.md
|
||||
fi
|
||||
|
||||
if [ -n "$REFACTORS" ]; then
|
||||
echo "### 🔨 Refactoring" >> NEW_CHANGELOG.md
|
||||
echo -e "$REFACTORS" >> NEW_CHANGELOG.md
|
||||
fi
|
||||
|
||||
# Get existing releases (everything after first ## [version] pattern)
|
||||
sed -n '/## \[[0-9]/,$p' CHANGELOG.md >> NEW_CHANGELOG.md
|
||||
|
||||
# Replace the original file
|
||||
mv NEW_CHANGELOG.md CHANGELOG.md
|
||||
else
|
||||
echo -e "$CHANGELOG" > CHANGELOG.md
|
||||
fi
|
||||
|
||||
# Set output for GitHub release (escape newlines)
|
||||
{
|
||||
echo 'changelog<<EOF'
|
||||
echo -e "$CHANGELOG"
|
||||
echo EOF
|
||||
} >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create GitHub Release
|
||||
if: steps.version_bump.outputs.should_release == 'true'
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: v${{ steps.version_bump.outputs.new_version }}
|
||||
release_name: Release v${{ steps.version_bump.outputs.new_version }}
|
||||
body: ${{ steps.changelog.outputs.changelog }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
set -e # Exit on any error
|
||||
|
||||
# Ensure non-interactive mode for apt
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
echo "Installing PostgreSQL client tools versions 13-17 for Linux (Debian/Ubuntu)..."
|
||||
echo
|
||||
|
||||
@@ -30,18 +33,18 @@ echo
|
||||
|
||||
# Add PostgreSQL official APT repository
|
||||
echo "Adding PostgreSQL official APT repository..."
|
||||
$SUDO apt-get update -qq
|
||||
$SUDO apt-get install -y wget ca-certificates
|
||||
$SUDO apt-get update -qq -y
|
||||
$SUDO apt-get install -y -qq wget ca-certificates
|
||||
|
||||
# Add GPG key
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | $SUDO apt-key add -
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | $SUDO apt-key add - 2>/dev/null
|
||||
|
||||
# Add repository
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | $SUDO tee /etc/apt/sources.list.d/pgdg.list
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | $SUDO tee /etc/apt/sources.list.d/pgdg.list >/dev/null
|
||||
|
||||
# Update package list
|
||||
echo "Updating package list..."
|
||||
$SUDO apt-get update -qq
|
||||
$SUDO apt-get update -qq -y
|
||||
|
||||
# Install client tools for each version
|
||||
versions="13 14 15 16 17"
|
||||
@@ -50,35 +53,34 @@ for version in $versions; do
|
||||
echo "Installing PostgreSQL $version client tools..."
|
||||
|
||||
# Install client tools only
|
||||
$SUDO apt-get install -y postgresql-client-$version
|
||||
$SUDO apt-get install -y -qq postgresql-client-$version
|
||||
|
||||
# Create version-specific directory and symlinks
|
||||
version_dir="$POSTGRES_DIR/postgresql-$version"
|
||||
mkdir -p "$version_dir/bin"
|
||||
|
||||
# Create symlinks to the installed binaries
|
||||
if [ -f "/usr/bin/pg_dump" ]; then
|
||||
# If multiple versions, binaries are usually named with version suffix
|
||||
if [ -f "/usr/bin/pg_dump-$version" ]; then
|
||||
ln -sf "/usr/bin/pg_dump-$version" "$version_dir/bin/pg_dump"
|
||||
ln -sf "/usr/bin/pg_dumpall-$version" "$version_dir/bin/pg_dumpall"
|
||||
ln -sf "/usr/bin/psql-$version" "$version_dir/bin/psql"
|
||||
ln -sf "/usr/bin/pg_restore-$version" "$version_dir/bin/pg_restore"
|
||||
ln -sf "/usr/bin/createdb-$version" "$version_dir/bin/createdb"
|
||||
ln -sf "/usr/bin/dropdb-$version" "$version_dir/bin/dropdb"
|
||||
else
|
||||
# Fallback to non-versioned names (latest version)
|
||||
ln -sf "/usr/bin/pg_dump" "$version_dir/bin/pg_dump"
|
||||
ln -sf "/usr/bin/pg_dumpall" "$version_dir/bin/pg_dumpall"
|
||||
ln -sf "/usr/bin/psql" "$version_dir/bin/psql"
|
||||
ln -sf "/usr/bin/pg_restore" "$version_dir/bin/pg_restore"
|
||||
ln -sf "/usr/bin/createdb" "$version_dir/bin/createdb"
|
||||
ln -sf "/usr/bin/dropdb" "$version_dir/bin/dropdb"
|
||||
fi
|
||||
# On Debian/Ubuntu, PostgreSQL binaries are located in /usr/lib/postgresql/{version}/bin/
|
||||
pg_bin_dir="/usr/lib/postgresql/$version/bin"
|
||||
|
||||
if [ -d "$pg_bin_dir" ] && [ -f "$pg_bin_dir/pg_dump" ]; then
|
||||
# Create symlinks to the version-specific binaries
|
||||
ln -sf "$pg_bin_dir/pg_dump" "$version_dir/bin/pg_dump"
|
||||
ln -sf "$pg_bin_dir/pg_dumpall" "$version_dir/bin/pg_dumpall"
|
||||
ln -sf "$pg_bin_dir/psql" "$version_dir/bin/psql"
|
||||
ln -sf "$pg_bin_dir/pg_restore" "$version_dir/bin/pg_restore"
|
||||
ln -sf "$pg_bin_dir/createdb" "$version_dir/bin/createdb"
|
||||
ln -sf "$pg_bin_dir/dropdb" "$version_dir/bin/dropdb"
|
||||
|
||||
echo "PostgreSQL $version client tools installed successfully"
|
||||
else
|
||||
echo "Warning: PostgreSQL $version client tools may not have installed correctly"
|
||||
echo "Error: PostgreSQL $version binaries not found in expected location: $pg_bin_dir"
|
||||
echo "Available PostgreSQL directories:"
|
||||
ls -la /usr/lib/postgresql/ 2>/dev/null || echo "No PostgreSQL directories found in /usr/lib/postgresql/"
|
||||
if [ -d "$pg_bin_dir" ]; then
|
||||
echo "Contents of $pg_bin_dir:"
|
||||
ls -la "$pg_bin_dir" 2>/dev/null || echo "Directory exists but cannot list contents"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
done
|
||||
@@ -93,6 +95,9 @@ for version in $versions; do
|
||||
version_dir="$POSTGRES_DIR/postgresql-$version"
|
||||
if [ -f "$version_dir/bin/pg_dump" ]; then
|
||||
echo " postgresql-$version: $version_dir/bin/"
|
||||
# Verify the correct version
|
||||
version_output=$("$version_dir/bin/pg_dump" --version 2>/dev/null | grep -o "pg_dump (PostgreSQL) [0-9]\+\.[0-9]\+")
|
||||
echo " Version check: $version_output"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
This directory is needed only for development.
|
||||
This directory is needed only for development and CI\CD.
|
||||
|
||||
We have to download and install all the PostgreSQL versions from 13 to 17 locally.
|
||||
This is needed so we can call pg_dump, pg_dumpall, etc. on each version of the PostgreSQL database.
|
||||
|
||||
Reference in New Issue
Block a user