Skip to content

Commit 68f8d12

Browse files
committed
ci: refactor Github release definitions with pre-releases and deliverables support
1 parent 2eebcc4 commit 68f8d12

29 files changed

Lines changed: 253 additions & 174 deletions

.github/workflows/docker_publish.yml

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ permissions:
66
on:
77
push:
88
tags: ["v*"]
9+
branches: ["v*"]
910
# Allows you to run this workflow manually from the Actions tab
1011
workflow_dispatch:
1112

@@ -26,9 +27,22 @@ jobs:
2627
username: ${{ secrets.DOCKER_USER_LOGIN }}
2728
password: ${{ secrets.DOCKER_USER_PASSWORD }}
2829

29-
- name: Extract version from mysqltuner.pl
30+
- name: Extract version and tag logic
3031
id: version
31-
run: echo "VERSION=$(grep '\- Version ' mysqltuner.pl | awk '{ print $NF}')" >> $GITHUB_ENV
32+
run: |
33+
VERSION=$(grep '\- Version ' mysqltuner.pl | awk '{ print $NF}')
34+
echo "VERSION=$VERSION" >> $GITHUB_ENV
35+
36+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
37+
TAG_NAME=${GITHUB_REF#refs/tags/}
38+
IS_PRERELEASE="false"
39+
else
40+
TAG_NAME=${GITHUB_REF#refs/heads/}
41+
IS_PRERELEASE="true"
42+
fi
43+
44+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
45+
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_ENV
3246
3347
- name: Pre-publish validation
3448
run: |
@@ -49,13 +63,16 @@ jobs:
4963
fi
5064
echo "✔ Found release notes"
5165
52-
TAG=${GITHUB_REF#refs/tags/}
53-
echo "Checking tag consistency (Tag: $TAG vs Version: v${{ env.VERSION }})..."
54-
if [ "v${{ env.VERSION }}" != "$TAG" ]; then
55-
echo "ERROR: Tag $TAG does not match version in mysqltuner.pl (v${{ env.VERSION }})"
56-
exit 1
66+
if [ "${{ env.IS_PRERELEASE }}" == "false" ]; then
67+
echo "Checking tag consistency (Tag: ${{ env.TAG_NAME }} vs Version: v${{ env.VERSION }})..."
68+
if [ "v${{ env.VERSION }}" != "${{ env.TAG_NAME }}" ]; then
69+
echo "ERROR: Tag ${{ env.TAG_NAME }} does not match version in mysqltuner.pl (v${{ env.VERSION }})"
70+
exit 1
71+
fi
72+
echo "✔ Tag matches script version"
73+
else
74+
echo "ℹ Skipping tag consistency check (not a tag push)"
5775
fi
58-
echo "✔ Tag matches script version"
5976
6077
- name: Extract release notes
6178
id: release_notes
@@ -66,14 +83,29 @@ jobs:
6683
echo 'EOF'
6784
} >> $GITHUB_ENV
6885
86+
- name: Prepare Docker Tags
87+
id: docker_tags
88+
run: |
89+
TAGS="jmrenouard/mysqltuner:${{ env.VERSION }}"
90+
if [ "${{ env.VERSION }}" != "${{ env.TAG_NAME }}" ]; then
91+
TAGS="${TAGS}\njmrenouard/mysqltuner:${{ env.TAG_NAME }}"
92+
fi
93+
if [ "${{ env.IS_PRERELEASE }}" == "false" ]; then
94+
TAGS="${TAGS}\njmrenouard/mysqltuner:latest"
95+
fi
96+
# Print multiline correctly for Github outputs / env
97+
{
98+
echo 'DOCKER_IMAGE_TAGS<<EOF'
99+
echo -e "$TAGS"
100+
echo 'EOF'
101+
} >> $GITHUB_ENV
102+
69103
- name: Build and push Docker image
70104
uses: docker/build-push-action@v7
71105
with:
72106
context: .
73107
push: true
74-
tags: |
75-
jmrenouard/mysqltuner:latest
76-
jmrenouard/mysqltuner:${{ env.VERSION }}
108+
tags: ${{ env.DOCKER_IMAGE_TAGS }}
77109
labels: |
78110
org.opencontainers.image.title=MySQLTuner
79111
org.opencontainers.image.description=**MySQLTuner** is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief format along with some basic performance suggestions. **MySQLTuner** supports ~300 indicators for MySQL/MariaDB/Percona Server in this latest version.
Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
name: Create Release
2+
13
on:
24
push:
3-
# Sequence of patterns matched against refs/tags
4-
tags:
5-
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
6-
7-
name: Create Release
5+
tags: ["v*"]
6+
branches: ["v*"]
7+
workflow_dispatch:
88

99
permissions:
1010
contents: write
@@ -17,15 +17,84 @@ jobs:
1717
- name: Checkout code
1818
uses: actions/checkout@v6
1919

20-
- name: Create Release and Upload Assets
20+
- name: Set Release Info
21+
id: rel_info
22+
run: |
23+
VERSION=$(grep '\- Version ' mysqltuner.pl | awk '{ print $NF}')
24+
echo "VERSION=$VERSION" >> $GITHUB_ENV
25+
26+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
27+
TAG_NAME=${GITHUB_REF#refs/tags/}
28+
IS_PRERELEASE="false"
29+
else
30+
TAG_NAME=${GITHUB_REF#refs/heads/}
31+
IS_PRERELEASE="true"
32+
fi
33+
34+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
35+
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_ENV
36+
37+
- name: Pre-publish validation
38+
run: |
39+
echo "Checking for critical files..."
40+
CRITICAL_FILES=("mysqltuner.pl" "basic_passwords.txt" "vulnerabilities.csv")
41+
for file in "${CRITICAL_FILES[@]}"; do
42+
if [ ! -f "$file" ]; then
43+
echo "ERROR: Critical file missing: $file"
44+
exit 1
45+
fi
46+
# Generate SHA256 sum
47+
sha256sum "$file" > "$file.sha256"
48+
done
49+
50+
- name: Generate Beautiful Release Notes
51+
run: |
52+
# 1. Start with the real release notes
53+
if [ -f "releases/v${VERSION}.md" ]; then
54+
cat "releases/v${VERSION}.md" > release_body.md
55+
else
56+
echo "# Release ${TAG_NAME}" > release_body.md
57+
fi
58+
59+
# 2. Add Deliverables Section
60+
{
61+
echo ""
62+
echo "---"
63+
echo "## Deliverables"
64+
echo ""
65+
echo "### Standalone Script & Data"
66+
echo "| Asset | Checksum |"
67+
echo "|---|---|"
68+
echo "| \`mysqltuner.pl\` | [sha256] |"
69+
echo "| \`basic_passwords.txt\` | [sha256] |"
70+
echo "| \`vulnerabilities.csv\` | [sha256] |"
71+
echo ""
72+
echo "### Docker Images"
73+
echo "\`\`\`bash"
74+
echo "docker pull jmrenouard/mysqltuner:${VERSION}"
75+
if [ "${IS_PRERELEASE}" == "false" ]; then
76+
echo "docker pull jmrenouard/mysqltuner:latest"
77+
fi
78+
echo "\`\`\`"
79+
echo ""
80+
echo "---"
81+
echo "*Checksums (.sha256) are available in the assets list below.*"
82+
} >> release_body.md
83+
84+
- name: Create GitHub Release
2185
uses: softprops/action-gh-release@v3
2286
with:
87+
tag_name: ${{ env.TAG_NAME }}
88+
name: "${{ env.TAG_NAME }}"
89+
body_path: release_body.md
90+
prerelease: ${{ env.IS_PRERELEASE == 'true' }}
91+
generate_release_notes: false
2392
files: |
2493
mysqltuner.pl
25-
body: |
26-
Changes in this Release:
27-
Please consult commit log and issue tracker on Github for more information.
28-
draft: true
29-
prerelease: false
94+
mysqltuner.pl.sha256
95+
basic_passwords.txt
96+
basic_passwords.txt.sha256
97+
vulnerabilities.csv
98+
vulnerabilities.csv.sha256
3099
env:
31100
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build/audit_logs.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
if ($line =~ /Syntax error/i || $line =~ /unexpected/i) {
5757
push @anomalies, { file => $file_path, line => $line_num, type => 'Syntax Anomaly', content => $line };
5858
}
59-
if ($line =~ /uninitialized value/i || $line =~ /deprecated/i) {
59+
if ( ($line =~ /uninitialized value/i || $line =~ /deprecated/i) && $line !~ // ) {
6060
push @anomalies, { file => $file_path, line => $line_num, type => 'Perl Warning', content => $line };
6161
}
6262
}

tests/auth_plugin_checks.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use Cwd 'abs_path';
99
my $script_dir = dirname(abs_path(__FILE__));
1010
my $script = abs_path(File::Spec->catfile($script_dir, '..', 'mysqltuner.pl'));
1111
require $script;
12+
require './tests/MySQLTuner/TestHelper.pm';
1213

1314
# Mocking necessary database calls and variables
1415
no warnings 'redefine';

tests/cloud_discovery.t

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use Cwd 'abs_path';
1010
my $script_dir = dirname(abs_path(__FILE__));
1111
my $script = abs_path(File::Spec->catfile($script_dir, '..', 'mysqltuner.pl'));
1212
require $script;
13+
require './tests/MySQLTuner/TestHelper.pm';
1314

1415
# Mock global variables
1516
our %myvar;
@@ -19,7 +20,8 @@ our %result;
1920

2021
subtest 'mysql_cloud_discovery' => sub {
2122
# Case 1: AWS Aurora
22-
%main::myvar = (
23+
MySQLTuner::TestHelper::reset_state();
24+
%main::myvar = ( %main::myvar,
2325
'version_comment' => 'MySQL Community Server (GPL) - Aurora 3.0.0',
2426
'aurora_version' => '3.0.0'
2527
);
@@ -28,40 +30,46 @@ subtest 'mysql_cloud_discovery' => sub {
2830
ok($main::is_cloud, 'Sets is_cloud to 1');
2931

3032
# Case 2: AWS RDS
31-
%main::myvar = (
33+
MySQLTuner::TestHelper::reset_state();
34+
%main::myvar = ( %main::myvar,
3235
'version_comment' => 'RDS MySQL Server',
3336
'basedir' => '/rdsdbbin/mysql/'
3437
);
3538
is(main::mysql_cloud_discovery(), 'AWS RDS', 'Detects AWS RDS');
3639

3740
# Case 3: GCP Cloud SQL
38-
%main::myvar = (
41+
MySQLTuner::TestHelper::reset_state();
42+
%main::myvar = ( %main::myvar,
3943
'version_comment' => 'Google Cloud SQL',
4044
'socket' => '/cloudsql/project:region:instance'
4145
);
4246
is(main::mysql_cloud_discovery(), 'GCP Cloud SQL', 'Detects GCP Cloud SQL');
4347

4448
# Case 4: Azure Flexible Server
45-
%main::myvar = (
49+
MySQLTuner::TestHelper::reset_state();
50+
%main::myvar = ( %main::myvar,
4651
'version_comment' => 'Azure MySQL Flexible Server',
4752
'azure.tenant_id' => 'some-uid'
4853
);
4954
is(main::mysql_cloud_discovery(), 'Azure Flexible Server', 'Detects Azure Flexible Server');
5055

5156
# Case 5: Azure Managed (Single Server)
52-
%main::myvar = (
57+
MySQLTuner::TestHelper::reset_state();
58+
%main::myvar = ( %main::myvar,
5359
'version_comment' => 'Azure MySQL Managed Server'
5460
);
5561
is(main::mysql_cloud_discovery(), 'Azure Managed MySQL', 'Detects Azure Managed MySQL');
5662

5763
# Case 6: DigitalOcean
58-
%main::myvar = (
64+
MySQLTuner::TestHelper::reset_state();
65+
%main::myvar = ( %main::myvar,
5966
'version_comment' => 'DigitalOcean Managed MySQL'
6067
);
6168
is(main::mysql_cloud_discovery(), 'DigitalOcean Managed MySQL', 'Detects DigitalOcean');
6269

6370
# Case 7: None
64-
%main::myvar = (
71+
MySQLTuner::TestHelper::reset_state();
72+
%main::myvar = ( %main::myvar,
6573
'version_comment' => 'MySQL Community Server (GPL)'
6674
);
6775
is(main::mysql_cloud_discovery(), 'none', 'Detects no cloud environment');

0 commit comments

Comments
 (0)