Skip to content

Commit

Permalink
Merge pull request #103 from he4rt/feat/gh-release-script
Browse files Browse the repository at this point in the history
feature(ci): add release github actions
  • Loading branch information
CodeLieutenant authored Aug 12, 2024
2 parents 871d2ed + ab29c67 commit f30ffae
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 60 deletions.
59 changes: 27 additions & 32 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
name: 'Docker Test Image'
name: "Build Docker Image"

on:
workflow_dispatch:
inputs:
php:
description: 'PHP Version'
description: "PHP Version"
required: true
zts:
description: 'ZTS (Zend Thread Safety)'
description: "ZTS (Zend Thread Safety)"
required: true
ubuntu_version:
type: string
description: 'Ubuntu Version'
required: false
default: '22.04'
default: '24.04'
workflow_call:
inputs:
php:
type: string
description: 'PHP Version'
description: "PHP Version"
required: true
debug:
type: string
description: "PHP Debug -> Options [yes, no]"
required: false
zts:
type: string
description: 'ZTS (Zend Thread Safety)'
description: "ZTS (Zend Thread Safety) -> Options [yes, no]"
required: true
ubuntu_version:
type: string
description: 'Ubuntu Version'
description: "Ubuntu Version -> Options [20.04, 22.04, 24.04]"
required: false
default: '22.04'
default: "24.04"
secrets:
DOCKER_USERNAME:
required: true
Expand All @@ -52,42 +56,33 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push API
id: docker_build_zts
uses: docker/build-push-action@v5
if: ${{ inputs.zts == 'yes' }}
with:
file: ./docker/Dockerfile
context: .
push: true
pull: true
platforms: linux/amd64
target: final
tags: malusevd99/scylladb-php-driver:ubuntu-${{ inputs.ubuntu_version }}-php-${{ inputs.php }}-zts
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PHP_VERSION=${{ inputs.php }}
PHP_ZTS=${{ inputs.zts }}
UBUNTU_VERSION=${{ inputs.ubuntu_version }}
PHP_DEBUG="yes"
- name: Extract PHP Version and ZTS
id: version
run: |
export PHP_VERSION="$(echo ${{ inputs.php }} | grep -oP '^\d+\.\d+')"
PHP_ENDING="php-$PHP_VERSION"
[[ ${{ inputs.zts }} == "yes" ]] && PHP_ENDING="$PHP_ENDING-zts"
[[ ${{ inputs.debug }} == "yes" ]] && PHP_ENDING="$PHP_ENDING-debug"
echo "php_ending=$PHP_ENDING" >> $GITHUB_ENV
- name: Build and push API
id: docker_build_nts
id: docker_build
uses: docker/build-push-action@v5
if: ${{ inputs.zts == 'no' }}
with:
file: ./docker/Dockerfile
context: .
push: true
pull: true
platforms: linux/amd64
target: final
tags: malusevd99/scylladb-php-driver:ubuntu-${{ inputs.ubuntu_version }}-php-${{ inputs.php }}
tags: malusevd99/scylladb-php-driver:ubuntu-${{ inputs.ubuntu_version }}-${{ steps.version.outputs.php_ending }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
UBUNTU_VERSION=${{ inputs.ubuntu_version }}
PHP_VERSION=${{ inputs.php }}
PHP_ZTS=${{ inputs.zts }}
UBUNTU_VERSION=${{ inputs.ubuntu_version }}
PHP_DEBUG="yes"
PHP_DEBUG=${{ inputs.debug }}
PHP_MEM_SANITIZERS=${{ inputs.debug }}
109 changes: 109 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: "Release"

permissions:
contents: write

on:
push:
tags:
- "v*"

jobs:
tag:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tag.outputs.tag }}
prerelease: ${{ (!!steps.prerelease.outputs.is_prerelease) || false }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get Tag
if: startsWith(github.ref, 'refs/tags/v')
uses: olegtarasov/get-tag@v2.1.3
id: tag
with:
tagRegex: "v(.*)"
- name: Get Prerelease
if: contains(github.ref, '-rc') || contains(github.ref, '-pre') || contains(github.ref, '-alpha') || contains(github.ref, '-beta')
run: echo "is_prerelease=true" >> $GITHUB_OUTPUT
id: prerelease

build:
runs-on: ubuntu-latest
needs: ['tag']
strategy:
matrix:
php: ['8.1', '8.1-zts', '8.2', '8.2-zts', '8.3', '8.3-zts']
os: ['ubuntu-20.04', 'ubuntu-24.04']
preset: ['CICassandra', 'CIScylla']
fail-fast: true
container: malusevd99/scylladb-php-driver:${{ matrix.os }}-php-${{ matrix.php }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Extract PHP Version and ZTS
id: name
run: |
[ "CICassandra" = "${{ matrix.preset }}" ] && echo 'extension="cassandra-${{ matrix.os }}-${{ matrix.php }}"' >> $GITHUB_ENV
[ "CIScylla" = "${{ matrix.preset }}" ] && echo 'extension="scylla-${{ matrix.os }}-${{ matrix.php }}"' >> $GITHUB_ENV
- name: Build Driver
run: |
cmake --preset ${{ matrix.preset }} -DPHP_SCYLLADB_VERSION=${{ needs.tag.outputs.version }} || exit 1
cd out/${{ matrix.preset }} || exit 1
ninja build || exit 1
cd ../../
mv out/${{ matrix.preset }}/cassandra.so || exit 1
sed -i "s/extension = cassandra/extension = ${{ steps.name.outputs.extension }}/g" cassandra.ini || exit 1
tar czf ${{ steps.name.outputs.extension }}.tar.gz ${{ steps.name.outputs.extension }}.so cassandra.ini
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.name.outputs.extension }}
path: ${{ steps.name.outputs.extension }}.tar.gz
if-no-files-found: error
retention-days: 5
overwrite: true

release:
runs-on: ubuntu-latest
needs: ["build", 'tag']
steps:
- uses: actions/download-artifact@v4
id: artifacts
with:
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v2
id: release
with:
make_latest: ${{ !needs.tag.outputs.prerelease }}
name: "v${{ needs.tag.outputs.version }}"
tag_name: "v${{ needs.tag.outputs.version }}"
generate_release_notes: true
append_body: true
prerelease: ${{ needs.tag.outputs.prerelease }}
files: |
${{ steps.artifacts.outputs.download-path }}/*.tar.gz
fail_on_unmatched_files: true
- name: "Generate release changelog"
uses: heinrichreimer/action-github-changelog-generator@v2.4
with:
token: ${{ secrets.GITHUB_TOKEN }}
author: true
releaseUrl: ${{ steps.release.outputs.url }}
issues: true
pullRequests: true
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update CHANGELOG.md"
branch: v1.3.x
commit_options: "--no-verify --signoff"
file_pattern: CHANGELOG.md
14 changes: 8 additions & 6 deletions .github/workflows/test-images.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
name: 'Build Docker Images for Testing'
name: "Build Docker Images"

on:
schedule:
- cron: '0 0 1,15 * *'
- cron: "0 0 1,15 * *"
workflow_call:
workflow_dispatch:

jobs:
build:
strategy:
matrix:
tag: ['8.1.29', '8.2.20', '8.3.8']
zts: [yes, no]
ubuntu_version: ['20.04', '22.04', '24.04']
tag: ["8.1.29", "8.2.20", "8.3.8"]
zts: ['yes', 'no']
debug: ['yes', 'no']
ubuntu_version: ["20.04", "22.04", "24.04"]
uses: "./.github/workflows/docker-image.yml"
with:
php: ${{ matrix.tag }}
zts: ${{ matrix.zts }}
ubuntu_version: ${{ matrix.ubuntu_version }}
debug: ${{ matrix.debug }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Test PHP Extension'
name: "Test PHP Extension"

on:
workflow_call:
Expand All @@ -12,12 +12,12 @@ jobs:
test:
strategy:
matrix:
php: ['8.1.29', '8.2.20', '8.3.8', '8.1.29-zts', '8.2.20-zts', '8.3.8-zts']
php: ['8.1', '8.2', '8.3', '8.1-zts', '8.2-zts', '8.3-zts']
os: ['ubuntu-20.04', 'ubuntu-24.04']
preset: ['CICassandra', 'CIScylla']
preset: ['CICassandraDebug', 'CIScyllaDebug']
fail-fast: false
runs-on: ubuntu-latest
container: malusevd99/scylladb-php-driver:${{ matrix.os }}-php-${{ matrix.php }}
container: malusevd99/scylladb-php-driver:${{ matrix.os }}-php-${{ matrix.php }}-debug
steps:
- uses: actions/checkout@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"files.associations": {
"*main.yml": "ansible",
"php_driver.h": "c",
"types.h": "c"
"types.h": "c",
"*.in": "c"
}
}
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Development

# 1.3.10

Expand Down
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ include(cmake/CPM.cmake)
include(cmake/TargetOptimizations.cmake)
include(cmake/ScyllaDBPHPLibrary.cmake)

set(PHP_SCYLLADB_VERSION_MAJOR 1)
set(PHP_SCYLLADB_VERSION_MINOR 3)
set(PHP_SCYLLADB_VERSION_PATCH 12)
set(PHP_SCYLLADB_STABILITY "devel")
set(PHP_SCYLLADB_VERSION_FULL "${PHP_SCYLLADB_VERSION_MAJOR}.${PHP_SCYLLADB_VERSION_MINOR}.${PHP_SCYLLADB_VERSION_PATCH}-${PHP_SCYLLADB_STABILITY}")
set(PHP_SCYLLADB_VERSION "${PHP_SCYLLADB_VERSION_MAJOR}.${PHP_SCYLLADB_VERSION_MINOR}.${PHP_SCYLLADB_VERSION_PATCH}-dev")
set(PHP_SCYLLADB_VERSION "1.4.0-dev")

set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
Expand Down
34 changes: 32 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,51 @@
"binaryDir": "${sourceDir}/out/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithInfo",
"PHP_SCYLLADB_ENABLE_SANITIZERS": "OFF",
"SANITIZE_UNDEFINED": "OFF",
"SANITIZE_ADDRESS": "OFF",
"CUSTOM_PHP_CONFIG": "/php/bin/php-config"
}
},
{
"name": "CICassandra",
"displayName": "GithubActions CI",
"description": "",
"generator": "Ninja",
"environment": {},
"binaryDir": "${sourceDir}/out/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithInfo",
"PHP_SCYLLADB_ENABLE_SANITIZERS": "OFF",
"SANITIZE_UNDEFINED": "OFF",
"SANITIZE_ADDRESS": "OFF",
"CUSTOM_PHP_CONFIG": "/php/bin/php-config"
}
},
{
"name": "CIScyllaDebug",
"displayName": "GithubActions CIScylla",
"description": "",
"generator": "Ninja",
"environment": {},
"binaryDir": "${sourceDir}/out/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"PHP_SCYLLADB_ENABLE_SANITIZERS": "ON",
"SANITIZE_UNDEFINED": "ON",
"SANITIZE_ADDRESS": "ON",
"CUSTOM_PHP_CONFIG": "/php/bin/php-config"
}
},
{
"name": "CICassandra",
"name": "CICassandraDebug",
"displayName": "GithubActions CI",
"description": "",
"generator": "Ninja",
"environment": {},
"binaryDir": "${sourceDir}/out/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithInfo",
"CMAKE_BUILD_TYPE": "Debug",
"PHP_SCYLLADB_ENABLE_SANITIZERS": "ON",
"SANITIZE_UNDEFINED": "ON",
"SANITIZE_ADDRESS": "ON",
Expand Down
3 changes: 1 addition & 2 deletions src/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ void php_driver_define_Core() {
zend_declare_class_constant_string(php_driver_core_ce, ZEND_STRL("TYPE_INET"),
"inet");

zend_declare_class_constant_string(php_driver_core_ce, ZEND_STRL("VERSION"),
PHP_DRIVER_VERSION_FULL);
zend_declare_class_constant_string(php_driver_core_ce, ZEND_STRL("VERSION"), PHP_DRIVER_VERSION);

snprintf(buf, sizeof(buf), "%d.%d.%d%s", CASS_VERSION_MAJOR,
CASS_VERSION_MINOR, CASS_VERSION_PATCH,
Expand Down
7 changes: 1 addition & 6 deletions version.h.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#pragma once

#define PHP_DRIVER_NAME "cassandra"
#define PHP_DRIVER_MAJOR @PHP_SCYLLADB_VERSION_MAJOR@
#define PHP_DRIVER_MINOR @PHP_SCYLLADB_VERSION_MINOR@
#define PHP_DRIVER_RELEASE @PHP_SCYLLADB_VERSION_PATCH@
#define PHP_DRIVER_STABILITY "@PHP_SCYLLADB_STABILITY@"
#define PHP_DRIVER_VERSION "@PHP_SCYLLADB_VERSION@"
#define PHP_DRIVER_VERSION_FULL "@PHP_SCYLLADB_VERSION_FULL@"
#define PHP_DRIVER_VERSION "@PHP_SCYLLADB_VERSION@"

0 comments on commit f30ffae

Please sign in to comment.