Merge pull request #30 from bordeux/feature/new-packages-build #30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| # ============================================ | |
| # Semantic Release - Determine Version | |
| # ============================================ | |
| semantic-release: | |
| name: Semantic Release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new_release_published: ${{ steps.semantic.outputs.new_release_published }} | |
| new_release_version: ${{ steps.semantic.outputs.new_release_version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run semantic-release | |
| id: semantic | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| HUSKY: 0 | |
| run: | | |
| # Get current tags | |
| BEFORE_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none") | |
| # Run semantic-release | |
| npx semantic-release 2>&1 | tee release-output.log | |
| # Check if a new tag was created | |
| AFTER_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none") | |
| if [ "$BEFORE_TAG" != "$AFTER_TAG" ] && [ "$AFTER_TAG" != "none" ]; then | |
| echo "new_release_published=true" >> $GITHUB_OUTPUT | |
| VERSION=$(echo "$AFTER_TAG" | sed 's/^v//') | |
| echo "new_release_version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Release published: $VERSION" | |
| else | |
| echo "new_release_published=false" >> $GITHUB_OUTPUT | |
| echo "No release published" | |
| fi | |
| - name: Output release info | |
| run: | | |
| echo "New release published: ${{ steps.semantic.outputs.new_release_published }}" | |
| echo "New release version: ${{ steps.semantic.outputs.new_release_version }}" | |
| # ============================================ | |
| # Build Binaries (reusable workflow) | |
| # ============================================ | |
| build-binaries: | |
| name: Build Binaries | |
| needs: semantic-release | |
| if: needs.semantic-release.outputs.new_release_published == 'true' | |
| uses: ./.github/workflows/_build-binaries.yml | |
| with: | |
| upload-artifacts: true | |
| artifact-retention-days: 1 | |
| # ============================================ | |
| # Build Packages (reusable workflow) | |
| # ============================================ | |
| build-packages: | |
| name: Build Packages | |
| needs: semantic-release | |
| if: needs.semantic-release.outputs.new_release_published == 'true' | |
| uses: ./.github/workflows/_build-packages.yml | |
| with: | |
| version: ${{ needs.semantic-release.outputs.new_release_version }} | |
| artifact-retention-days: 1 | |
| # ============================================ | |
| # Upload Release Assets | |
| # ============================================ | |
| upload-release-assets: | |
| name: Upload Release Assets | |
| needs: [semantic-release, build-binaries, build-packages] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Display structure | |
| run: ls -R artifacts | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ needs.semantic-release.outputs.new_release_version }} | |
| files: artifacts/**/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # ============================================ | |
| # Docker Build & Push | |
| # ============================================ | |
| docker: | |
| name: Build and Push Docker Image | |
| needs: [semantic-release, build-binaries] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ needs.semantic-release.outputs.new_release_version }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=semver,pattern={{version}},value=${{ needs.semantic-release.outputs.new_release_version }} | |
| type=semver,pattern={{major}}.{{minor}},value=${{ needs.semantic-release.outputs.new_release_version }} | |
| type=semver,pattern={{major}},value=${{ needs.semantic-release.outputs.new_release_version }} | |
| type=raw,value=latest | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64,linux/arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # ============================================ | |
| # Trigger External Package Repository Updates | |
| # ============================================ | |
| update-package-repos: | |
| name: Trigger ${{ matrix.name }} Update | |
| needs: [semantic-release, upload-release-assets] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - name: Homebrew | |
| repo: bordeux/homebrew-tap | |
| token_env: HOMEBREW_TAP_TOKEN | |
| - name: APT Repository | |
| repo: bordeux/apt-repo | |
| token_env: APT_REPO_TOKEN | |
| - name: APK Repository | |
| repo: bordeux/apk-repo | |
| token_env: APK_REPO_TOKEN | |
| - name: RPM Repository | |
| repo: bordeux/rpm-repo | |
| token_env: RPM_REPO_TOKEN | |
| - name: ARCH Repository | |
| repo: bordeux/arch-repo | |
| token_env: ARCH_REPO_TOKEN | |
| steps: | |
| - name: Trigger ${{ matrix.name }} workflow | |
| env: | |
| HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| APT_REPO_TOKEN: ${{ secrets.APT_REPO_TOKEN }} | |
| APK_REPO_TOKEN: ${{ secrets.APK_REPO_TOKEN }} | |
| RPM_REPO_TOKEN: ${{ secrets.RPM_REPO_TOKEN }} | |
| ARCH_REPO_TOKEN: ${{ secrets.ARCH_REPO_TOKEN }} | |
| run: | | |
| TOKEN_VAR="${{ matrix.token_env }}" | |
| TOKEN="${!TOKEN_VAR}" | |
| curl -X POST \ | |
| -H "Authorization: token $TOKEN" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| "https://api.github.com/repos/${{ matrix.repo }}/actions/workflows/update-repo.yml/dispatches" \ | |
| -d '{"ref":"master","inputs":{"project":"bordeux/tmpltool"}}' |