name: Release on: push: tags: - 'v*' workflow_dispatch: inputs: tag: description: 'Tag to release' required: true type: string env: REGISTRY: ghcr.io jobs: create-release: runs-on: ubuntu-latest permissions: contents: write packages: read outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} release_id: ${{ steps.create_release.outputs.id }} steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Get tag id: get_tag run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT else echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT fi - name: Generate changelog id: changelog run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then PREVIOUS_TAG=$(git describe --tags --abbrev=0 "${{ github.event.inputs.tag }}^" 2>/dev/null || echo "") else PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") fi if [ -n "$PREVIOUS_TAG" ]; then echo "## Changes since $PREVIOUS_TAG" > changelog.md git log --pretty=format:"- %s (%h)" "$PREVIOUS_TAG"..HEAD >> changelog.md else echo "## Initial Release" > changelog.md echo "First release of Voice RSS Summary" >> changelog.md fi echo "" >> changelog.md echo "## Docker Images" >> changelog.md echo "- \`ghcr.io/${{ github.repository_owner }}/voice-rss-summary:${{ steps.get_tag.outputs.tag }}\`" >> changelog.md echo "- \`ghcr.io/${{ github.repository_owner }}/voicersssummary:${{ steps.get_tag.outputs.tag }}\`" >> changelog.md echo "" >> changelog.md echo "## Usage" >> changelog.md echo "\`\`\`bash" >> changelog.md echo "# Pull and run the latest image" >> changelog.md echo "docker run -p 3000:3000 -p 3001:3001 ghcr.io/${{ github.repository_owner }}/voice-rss-summary:${{ steps.get_tag.outputs.tag }}" >> changelog.md echo "" >> changelog.md echo "# Or clone the repository and run locally" >> changelog.md echo "git clone https://github.com/${{ github.repository }}.git" >> changelog.md echo "cd VoiceRSSSummary" >> changelog.md echo "git checkout ${{ steps.get_tag.outputs.tag }}" >> changelog.md echo "./run-docker.sh container-name ${{ steps.get_tag.outputs.tag }} --from-ghcr" >> changelog.md echo "\`\`\`" >> changelog.md - name: Create Release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ steps.get_tag.outputs.tag }} release_name: Release ${{ steps.get_tag.outputs.tag }} body_path: changelog.md draft: false prerelease: ${{ contains(steps.get_tag.outputs.tag, '-') }} wait-for-docker: runs-on: ubuntu-latest needs: create-release permissions: packages: read steps: - name: Get tag id: get_tag run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT else echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT fi - name: Wait for Docker images run: | echo "Waiting for Docker images to be available..." TAG="${{ steps.get_tag.outputs.tag }}" for i in {1..30}; do echo "Attempt $i: Checking if images are available..." if docker manifest inspect ghcr.io/${{ github.repository_owner }}/voice-rss-summary:${TAG} >/dev/null 2>&1; then echo "✅ Docker images are available!" exit 0 fi echo "Images not yet available, waiting 30 seconds..." sleep 30 done echo "❌ Timeout waiting for Docker images" exit 1 - name: Test Docker image run: | TAG="${{ steps.get_tag.outputs.tag }}" echo "Testing Docker image: ghcr.io/${{ github.repository_owner }}/voice-rss-summary:${TAG}" # Pull the image docker pull ghcr.io/${{ github.repository_owner }}/voice-rss-summary:${TAG} # Run a quick test docker run --rm --name test-container \ ghcr.io/${{ github.repository_owner }}/voice-rss-summary:${TAG} \ timeout 10 bun --version || true echo "✅ Docker image test completed"