Merge branch 'main' into production #1
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: Publish HushNet Docker image | |
| on: | |
| release: | |
| types: [published] | |
| push: | |
| branches: | |
| - production | |
| jobs: | |
| release: | |
| name: Publish GitHub Release | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/production' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract version from Cargo.toml | |
| id: version | |
| run: | | |
| VERSION=$(grep '^version' Cargo.toml | head -n 1 | cut -d '"' -f2) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| echo "Previous tag: $PREV_TAG" | |
| if [ -n "$PREV_TAG" ]; then | |
| LOG=$(git log $PREV_TAG..HEAD --pretty=format:"- %s (%an)") | |
| else | |
| LOG=$(git log --pretty=format:"- %s (%an)") | |
| fi | |
| echo "log<<EOF" >> $GITHUB_OUTPUT | |
| echo "$LOG" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: 🏷️ Create tag if not exists | |
| run: | | |
| TAG="v${{ steps.version.outputs.version }}" | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Tag $TAG already exists" | |
| else | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag "$TAG" | |
| git push origin "$TAG" | |
| fi | |
| - name: Publish GitHub Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| release_name: HushNet v${{ steps.version.outputs.version }} | |
| body: | | |
| ## 🛰️ HushNet Backend — Release v${{ steps.version.outputs.version }} | |
| **Branch:** `${{ github.ref_name }}` | |
| **Date:** $(date +"%Y-%m-%d") | |
| ### Changes since last release | |
| ${{ steps.changelog.outputs.log }} | |
| ### 🐳 Docker Image | |
| - [adamlbs/hushnet-backend:latest](https://hub.docker.com/r/adamlbs/hushnet-backend) | |
| - [adamlbs/hushnet-backend:v${{ steps.version.outputs.version }}](https://hub.docker.com/r/adamlbs/hushnet-backend/tags) | |
| --- | |
| _Built & released automatically by the CI/CD pipeline._ | |
| _Silent. Secure. Sovereign — HushNet_ | |
| push_to_registry: | |
| name: Push HushNet image to Docker Hub | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| contents: read | |
| attestations: write | |
| id-token: write | |
| steps: | |
| - name: 🧩 Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: adamlbs/hushnet-backend | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=latest | |
| - name: Build and push Docker image | |
| id: push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Generate artifact attestation (supply chain) | |
| uses: actions/attest-build-provenance@v3 | |
| with: | |
| subject-name: index.docker.io/adamllbs/hushnet-backend | |
| subject-digest: ${{ steps.push.outputs.digest }} | |
| push-to-registry: true |