v0.1.6 #6
Workflow file for this run
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: | |
tags: | |
- "v*" | |
env: | |
DOCKER_REPO: redislabs | |
DOCKER_IMAGE: client-resp-proxy | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install --frozen-lockfile | |
- name: Run linter | |
run: bun run lint | |
- name: Run tests | |
run: bun test | |
- name: Extract version from tag | |
id: version | |
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:latest | |
${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.VERSION }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Create GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Try to generate notes using GitHub's API first | |
GENERATED_NOTES=$(gh api repos/$GITHUB_REPOSITORY/releases/generate-notes -f tag_name=v${{ steps.version.outputs.VERSION }} --jq .body 2>/dev/null || echo "") | |
# If GitHub's generation worked and has content beyond just "Full Changelog" | |
if [[ "$GENERATED_NOTES" != *"**Full Changelog**"* ]] && [[ -n "$GENERATED_NOTES" ]]; then | |
RELEASE_BODY="## Docker Image | |
\`\`\`bash | |
docker pull ${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.VERSION }} | |
\`\`\` | |
$GENERATED_NOTES" | |
else | |
# Fallback to commit-based notes | |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
if [[ -n "$PREV_TAG" ]]; then | |
COMMIT_NOTES=$(git log ${PREV_TAG}..HEAD --pretty=format:"* %s (%h)" | head -20) | |
CHANGELOG_LINK="**Full Changelog**: https://github.com/$GITHUB_REPOSITORY/compare/${PREV_TAG}...v${{ steps.version.outputs.VERSION }}" | |
else | |
COMMIT_NOTES=$(git log --pretty=format:"* %s (%h)" | head -20) | |
CHANGELOG_LINK="" | |
fi | |
RELEASE_BODY="## Docker Image | |
\`\`\`bash | |
docker pull ${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.VERSION }} | |
\`\`\` | |
## What's Changed | |
$COMMIT_NOTES | |
$CHANGELOG_LINK" | |
fi | |
gh release create "v${{ steps.version.outputs.VERSION }}" \ | |
--repo="$GITHUB_REPOSITORY" \ | |
--title="Release ${{ steps.version.outputs.VERSION }}" \ | |
--notes "$RELEASE_BODY" \ | |
--draft |