chore(main): release 0.1.1 (#4) #8
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 Please | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: Existing release tag to publish (for example `v0.1.0`) | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| packages: write | |
| pull-requests: write | |
| concurrency: | |
| group: release-please-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| GHCR_IMAGE: ghcr.io/${{ github.repository }} | |
| jobs: | |
| release-please: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Release Please | |
| if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.tag_name == '' }} | |
| id: release | |
| uses: googleapis/release-please-action@v4 | |
| with: | |
| token: ${{ secrets.RELEASE_PLEASE_TOKEN }} | |
| config-file: .github/release-please-config.json | |
| manifest-file: .github/.release-please-manifest.json | |
| - name: Checkout workflow source | |
| uses: actions/checkout@v6 | |
| - name: Detect release context | |
| id: publish | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| manual_tag="${{ github.event.inputs.tag_name }}" | |
| if [ -n "${manual_tag}" ]; then | |
| release_json="$(gh release view "${manual_tag}" --json targetCommitish,url 2>/dev/null || true)" | |
| if [ -z "${release_json}" ]; then | |
| echo "Release ${manual_tag} not found" >&2 | |
| exit 1 | |
| fi | |
| echo "publish=true" >> "$GITHUB_OUTPUT" | |
| echo "tag_name=${manual_tag}" >> "$GITHUB_OUTPUT" | |
| echo "release_url=$(printf '%s' "${release_json}" | jq -r '.url')" >> "$GITHUB_OUTPUT" | |
| echo "checkout_ref=${manual_tag}" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if [ "${{ steps.release.outputs.release_created }}" = "true" ]; then | |
| echo "publish=true" >> "$GITHUB_OUTPUT" | |
| echo "tag_name=${{ steps.release.outputs.tag_name }}" >> "$GITHUB_OUTPUT" | |
| echo "release_url=${{ steps.release.outputs.html_url }}" >> "$GITHUB_OUTPUT" | |
| echo "checkout_ref=${{ steps.release.outputs.tag_name }}" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| version="$(jq -r '."."' .github/.release-please-manifest.json)" | |
| if [ -z "${version}" ] || [ "${version}" = "null" ]; then | |
| echo "publish=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| tag_name="v${version}" | |
| release_json="$(gh release view "${tag_name}" --json targetCommitish,url 2>/dev/null || true)" | |
| if [ -z "${release_json}" ]; then | |
| echo "publish=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| target_commitish="$(printf '%s' "${release_json}" | jq -r '.targetCommitish')" | |
| if [ "${target_commitish}" != "${GITHUB_SHA}" ]; then | |
| echo "publish=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "publish=true" >> "$GITHUB_OUTPUT" | |
| echo "tag_name=${tag_name}" >> "$GITHUB_OUTPUT" | |
| echo "release_url=$(printf '%s' "${release_json}" | jq -r '.url')" >> "$GITHUB_OUTPUT" | |
| echo "checkout_ref=${tag_name}" >> "$GITHUB_OUTPUT" | |
| - name: Checkout release source | |
| if: ${{ steps.publish.outputs.publish == 'true' }} | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ steps.publish.outputs.checkout_ref }} | |
| - name: Set up Docker Buildx | |
| if: ${{ steps.publish.outputs.publish == 'true' }} | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to GitHub Container Registry | |
| if: ${{ steps.publish.outputs.publish == 'true' }} | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| if: ${{ steps.publish.outputs.publish == 'true' }} | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ env.GHCR_IMAGE }} | |
| tags: | | |
| type=semver,pattern={{version}},value=${{ steps.publish.outputs.tag_name }} | |
| type=semver,pattern={{major}}.{{minor}},value=${{ steps.publish.outputs.tag_name }} | |
| type=semver,pattern={{major}},value=${{ steps.publish.outputs.tag_name }} | |
| type=raw,value=${{ steps.publish.outputs.tag_name }} | |
| type=raw,value=latest | |
| - name: Build and push Docker image | |
| if: ${{ steps.publish.outputs.publish == 'true' }} | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Detect template manifest | |
| if: ${{ steps.publish.outputs.publish == 'true' }} | |
| id: template | |
| run: | | |
| set -euo pipefail | |
| if [ -f Engram.yaml ]; then | |
| template_file="Engram.yaml" | |
| template_kind="EngramTemplate" | |
| elif [ -f Impulse.yaml ]; then | |
| template_file="Impulse.yaml" | |
| template_kind="ImpulseTemplate" | |
| else | |
| echo "Expected Engram.yaml or Impulse.yaml at repo root" >&2 | |
| exit 1 | |
| fi | |
| echo "file=${template_file}" >> "$GITHUB_OUTPUT" | |
| echo "kind=${template_kind}" >> "$GITHUB_OUTPUT" | |
| echo "latest_url=https://github.com/${{ github.repository }}/releases/latest/download/${template_file}" >> "$GITHUB_OUTPUT" | |
| echo "versioned_url=https://github.com/${{ github.repository }}/releases/download/${{ steps.publish.outputs.tag_name }}/${template_file}" >> "$GITHUB_OUTPUT" | |
| - name: Upload template manifest to GitHub release | |
| if: ${{ steps.publish.outputs.publish == 'true' }} | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release upload "${{ steps.publish.outputs.tag_name }}" "${{ steps.template.outputs.file }}" --clobber | |
| - name: Summarize release | |
| if: ${{ steps.publish.outputs.publish == 'true' }} | |
| run: | | |
| { | |
| echo "## Release ${{ steps.publish.outputs.tag_name }} 🚀" | |
| echo | |
| echo "- **GitHub Release**: ${{ steps.publish.outputs.release_url }}" | |
| echo "- **Container Image**: \`${{ env.GHCR_IMAGE }}:${{ steps.publish.outputs.tag_name }}\`" | |
| echo "- **Template Kind**: \`${{ steps.template.outputs.kind }}\`" | |
| echo "- **Latest Template URL**: ${{ steps.template.outputs.latest_url }}" | |
| echo "- **Pinned Template URL**: ${{ steps.template.outputs.versioned_url }}" | |
| echo | |
| echo "### Install the template" | |
| echo '```bash' | |
| echo "kubectl apply -f ${{ steps.template.outputs.latest_url }}" | |
| echo '```' | |
| echo | |
| echo "### Pull the image" | |
| echo '```bash' | |
| echo "docker pull ${{ env.GHCR_IMAGE }}:${{ steps.publish.outputs.tag_name }}" | |
| echo '```' | |
| } >> "$GITHUB_STEP_SUMMARY" |