name: Release on: push: tags: - 'v*' env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: release: runs-on: ubuntu-latest permissions: contents: write packages: write steps: - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 0 - name: Set up Helm uses: azure/setup-helm@v4 - name: Extract version from tag id: version run: | TAG=${GITHUB_REF#refs/tags/} VERSION=${TAG#v} echo "tag=${TAG}" >> $GITHUB_OUTPUT echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "🚀 Creating release for ${TAG}" - name: Package and Push Helm Chart run: | helm registry login ghcr.io \ --username ${{ github.actor }} \ --password ${{ secrets.GITHUB_TOKEN }} helm package chart/ helm push devcontainer-${{ steps.version.outputs.version }}.tgz oci://ghcr.io/cpfarhood/charts - name: Generate Release Notes id: notes run: | # Get commits since last tag PREV_TAG=$(git describe --tags --abbrev=0 ${{ steps.version.outputs.tag }}^ 2>/dev/null || echo "") if [ -z "$PREV_TAG" ]; then COMMITS=$(git log --pretty=format:"- %s (%h)" ${{ steps.version.outputs.tag }}) else COMMITS=$(git log --pretty=format:"- %s (%h)" ${PREV_TAG}..${{ steps.version.outputs.tag }}) fi cat << EOF > release-notes.md ## 🚀 Release ${{ steps.version.outputs.version }} ### Changes ${COMMITS} ### Docker Image \`\`\`bash docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }} \`\`\` ### Helm Chart \`\`\`bash helm install devcontainer oci://ghcr.io/cpfarhood/charts/devcontainer --version ${{ steps.version.outputs.version }} \`\`\` EOF echo "notes<> $GITHUB_OUTPUT cat release-notes.md >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - name: Create GitHub Release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ steps.version.outputs.tag }} release_name: Release ${{ steps.version.outputs.tag }} body: ${{ steps.notes.outputs.notes }} draft: false prerelease: false