chore(release): 1.0.0-alpha.3 #32
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*' | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| minor: ${{ steps.version.outputs.minor }} | |
| major: ${{ steps.version.outputs.major }} | |
| is_prerelease: ${{ steps.version.outputs.is_prerelease }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| ref: ${{ github.ref }} | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| TAG="${{ github.ref }}" | |
| VERSION=${TAG#refs/tags/v} | |
| VERSION=${VERSION#v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| MAJOR=$(echo $VERSION | cut -d. -f1) | |
| MINOR=$(echo $VERSION | cut -d. -f1-2) | |
| echo "major=$MAJOR" >> $GITHUB_OUTPUT | |
| echo "minor=$MINOR" >> $GITHUB_OUTPUT | |
| if [[ "$VERSION" == *-* ]]; then | |
| echo "is_prerelease=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_prerelease=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Find previous GitHub release | |
| id: previous_release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GH_PAGER: cat | |
| PAGER: cat | |
| run: | | |
| last=$(GH_PAGER=cat gh release list --limit 1 --json tagName --jq '.[0].tagName // ""') | |
| last=${last#v} | |
| echo "last=${last}" >> $GITHUB_OUTPUT | |
| - name: Extract changelog range | |
| id: changelog | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| LAST="${{ steps.previous_release.outputs.last }}" | |
| bash scripts/extract-changelog.sh CHANGELOG.md "$VERSION" "$LAST" > release-notes.md | |
| if [ ! -s release-notes.md ]; then | |
| echo "Release v${VERSION}" > release-notes.md | |
| fi | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| body_path: release-notes.md | |
| generate_release_notes: false | |
| prerelease: ${{ steps.version.outputs.is_prerelease == 'true' }} | |
| docker: | |
| name: Build and Push Docker Image | |
| runs-on: ubuntu-latest | |
| needs: release | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Compute Docker tags | |
| id: docker_tags | |
| run: | | |
| TAGS="${{ secrets.DOCKERHUB_USERNAME }}/tfplan2md:${{ needs.release.outputs.version }}" | |
| if [ "${{ needs.release.outputs.is_prerelease }}" != "true" ]; then | |
| TAGS="$TAGS\n${{ secrets.DOCKERHUB_USERNAME }}/tfplan2md:${{ needs.release.outputs.minor }}" | |
| TAGS="$TAGS\n${{ secrets.DOCKERHUB_USERNAME }}/tfplan2md:${{ needs.release.outputs.major }}" | |
| TAGS="$TAGS\n${{ secrets.DOCKERHUB_USERNAME }}/tfplan2md:latest" | |
| fi | |
| echo "tags<<EOF" >> $GITHUB_OUTPUT | |
| echo -e "$TAGS" >> $GITHUB_OUTPUT | |
| echo EOF >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.docker_tags.outputs.tags }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |