chore: prepare netbird v0.4.2 release (#78) #27
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: [main] | |
| paths: | |
| - "charts/*/Chart.yaml" | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| release: | |
| name: Release Charts | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Helm | |
| uses: azure/setup-helm@v4 | |
| with: | |
| version: v4.0.2 | |
| - name: Install oras | |
| uses: oras-project/setup-oras@v1 | |
| - name: Detect changed charts and release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| released=0 | |
| for chart_yaml in charts/*/Chart.yaml; do | |
| chart_dir=$(dirname "$chart_yaml") | |
| chart_name=$(basename "$chart_dir") | |
| version=$(grep '^version:' "$chart_yaml" | awk '{print $2}') | |
| tag="${chart_name}-${version}" | |
| # Skip if tag already exists (idempotent) | |
| if git rev-parse "refs/tags/${tag}" >/dev/null 2>&1; then | |
| echo "Tag ${tag} already exists — skipping ${chart_name}" | |
| continue | |
| fi | |
| echo "::group::Releasing ${chart_name} v${version}" | |
| # Login to GHCR | |
| echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u "${{ github.actor }}" --password-stdin | |
| # Package chart | |
| helm package "$chart_dir" | |
| # Push to OCI registry | |
| helm push "${chart_name}-${version}.tgz" oci://ghcr.io/kitstream/helms | |
| # Push ArtifactHub metadata | |
| echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u "${{ github.actor }}" --password-stdin | |
| oras push "ghcr.io/kitstream/helms/${chart_name}:artifacthub.io" \ | |
| --config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \ | |
| artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml | |
| # Create git tag | |
| git tag "$tag" | |
| git push origin "$tag" | |
| # Create GitHub Release | |
| gh release create "$tag" \ | |
| --title "$tag" \ | |
| --generate-notes \ | |
| "${chart_name}-${version}.tgz" | |
| echo "::endgroup::" | |
| released=$((released + 1)) | |
| done | |
| echo "Released ${released} chart(s)" |