|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: ['master', 'develop'] |
6 | | - tags: |
7 | | - - 'v*.*.*' |
8 | 6 | pull_request: |
9 | 7 | branches: ['master', 'develop', 'feature/*'] |
10 | 8 |
|
@@ -352,144 +350,14 @@ jobs: |
352 | 350 | fail-on-severity: moderate |
353 | 351 | comment-summary-in-pr: always |
354 | 352 |
|
355 | | - release: |
356 | | - name: Release |
357 | | - runs-on: ubuntu-latest |
358 | | - if: github.ref_type == 'tag' |
359 | | - permissions: |
360 | | - contents: write |
361 | | - needs: ['test'] |
362 | | - steps: |
363 | | - - uses: actions/checkout@v5 |
364 | | - with: |
365 | | - fetch-depth: 0 |
366 | | - |
367 | | - - name: Set up Go |
368 | | - uses: actions/setup-go@v6 |
369 | | - with: |
370 | | - go-version-file: 'go.mod' |
371 | | - check-latest: true |
372 | | - |
373 | | - - name: Run tests |
374 | | - run: | |
375 | | - echo "## 🚀 Release Tests" >> $GITHUB_STEP_SUMMARY |
376 | | - echo "" >> $GITHUB_STEP_SUMMARY |
377 | | -
|
378 | | - go test -v ./... 2>&1 | tee release-test-output.log |
379 | | - TEST_STATUS=$? |
380 | | -
|
381 | | - TOTAL_TESTS=$(grep -c "=== RUN" release-test-output.log || echo "0") |
382 | | - PASSED_TESTS=$(grep -c "--- PASS:" release-test-output.log || echo "0") |
383 | | - FAILED_TESTS=$(grep -c "--- FAIL:" release-test-output.log || echo "0") |
384 | | -
|
385 | | - echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY |
386 | | - echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY |
387 | | - echo "| Total Tests | $TOTAL_TESTS |" >> $GITHUB_STEP_SUMMARY |
388 | | - echo "| Passed | ✅ $PASSED_TESTS |" >> $GITHUB_STEP_SUMMARY |
389 | | - echo "| Failed | ❌ $FAILED_TESTS |" >> $GITHUB_STEP_SUMMARY |
390 | | - echo "| Status | $([ $TEST_STATUS -eq 0 ] && echo "✅ PASSED" || echo "❌ FAILED") |" >> $GITHUB_STEP_SUMMARY |
391 | | - echo "" >> $GITHUB_STEP_SUMMARY |
392 | | -
|
393 | | - exit $TEST_STATUS |
394 | | -
|
395 | | - - name: Install UPX |
396 | | - run: | |
397 | | - sudo apt-get update |
398 | | - sudo apt-get install -y upx |
399 | | -
|
400 | | - - name: Build binaries |
401 | | - run: | |
402 | | - echo "## 🔨 Build Process" >> $GITHUB_STEP_SUMMARY |
403 | | - echo "" >> $GITHUB_STEP_SUMMARY |
404 | | -
|
405 | | - # Set the build time environment variable using git commit timestamp |
406 | | - BUILD_TIME=$(git log -1 --format=%cd --date=iso-strict) |
407 | | -
|
408 | | - # Add run permissions to the build script |
409 | | - chmod +x ./scripts/build.sh |
410 | | -
|
411 | | - # Display help information for the build script |
412 | | - ./scripts/build.sh --help |
413 | | -
|
414 | | - echo "**Build Configuration:**" >> $GITHUB_STEP_SUMMARY |
415 | | - echo "- Version: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY |
416 | | - echo "- Build Time: $BUILD_TIME" >> $GITHUB_STEP_SUMMARY |
417 | | - echo "- Git Commit: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY |
418 | | - echo "" >> $GITHUB_STEP_SUMMARY |
419 | | -
|
420 | | - # Build for all platforms |
421 | | - ./scripts/build.sh \ |
422 | | - --verbose \ |
423 | | - -ldflags "-s -w -X github.com/kjanat/articulate-parser/internal/version.Version=${{ github.ref_name }} -X github.com/kjanat/articulate-parser/internal/version.BuildTime=$BUILD_TIME -X github.com/kjanat/articulate-parser/internal/version.GitCommit=${{ github.sha }}" |
424 | | -
|
425 | | - - name: Compress binaries with UPX |
426 | | - run: | |
427 | | - echo "## 📦 Binary Compression" >> $GITHUB_STEP_SUMMARY |
428 | | - echo "" >> $GITHUB_STEP_SUMMARY |
429 | | -
|
430 | | - echo "Compressing binaries with UPX..." |
431 | | - cd build/ |
432 | | -
|
433 | | - # Get original sizes |
434 | | - echo "**Original sizes:**" >> $GITHUB_STEP_SUMMARY |
435 | | - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
436 | | - ls -lah >> $GITHUB_STEP_SUMMARY |
437 | | - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
438 | | - echo "" >> $GITHUB_STEP_SUMMARY |
439 | | -
|
440 | | - # Compress all binaries except Darwin (macOS) binaries as UPX doesn't work well with recent macOS versions |
441 | | - for binary in articulate-parser-*; do |
442 | | - echo "Compressing $binary..." |
443 | | - upx --best "$binary" || { |
444 | | - echo "Warning: UPX compression failed for $binary, keeping original" |
445 | | - } |
446 | | -
|
447 | | - # if [[ "$binary" == *"darwin"* ]]; then |
448 | | - # echo "Skipping UPX compression for $binary (macOS compatibility)" |
449 | | - # else |
450 | | - # echo "Compressing $binary..." |
451 | | - # upx --best "$binary" || { # removed `--lzma` |
452 | | - # echo "Warning: UPX compression failed for $binary, keeping original" |
453 | | - # } |
454 | | - # fi |
455 | | - done |
456 | | -
|
457 | | - echo "**Final sizes:**" >> $GITHUB_STEP_SUMMARY |
458 | | - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
459 | | - ls -lah >> $GITHUB_STEP_SUMMARY |
460 | | - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
461 | | - echo "" >> $GITHUB_STEP_SUMMARY |
462 | | -
|
463 | | - - name: Upload a Build Artifact |
464 | | - |
465 | | - with: |
466 | | - name: build-artifacts |
467 | | - path: build/ |
468 | | - if-no-files-found: ignore |
469 | | - retention-days: 1 |
470 | | - compression-level: 9 |
471 | | - overwrite: true |
472 | | - include-hidden-files: true |
473 | | - |
474 | | - - name: Create Release |
475 | | - uses: softprops/action-gh-release@v2 |
476 | | - with: |
477 | | - files: build/* |
478 | | - generate_release_notes: true |
479 | | - draft: false |
480 | | - # Mark v0.x.x releases as prerelease (pre-1.0 versions are considered unstable) |
481 | | - prerelease: ${{ startsWith(github.ref, 'refs/tags/v0.') }} |
482 | | - env: |
483 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
484 | | - |
485 | 353 | docker: |
486 | 354 | name: Docker Build & Push |
487 | 355 | runs-on: ubuntu-latest |
488 | 356 | permissions: |
489 | 357 | contents: read |
490 | 358 | packages: write |
491 | 359 | needs: ['test'] |
492 | | - if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/feature/docker')) |
| 360 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/feature/docker')) |
493 | 361 | steps: |
494 | 362 | - name: Checkout repository |
495 | 363 | uses: actions/checkout@v5 |
|
0 commit comments