CD #2
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: CD | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (format: x.y.z)' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install git-chglog | |
| run: | | |
| CHGLOG_VERSION="0.15.4" | |
| wget -O /tmp/git-chglog.tar.gz https://github.com/git-chglog/git-chglog/releases/download/v${CHGLOG_VERSION}/git-chglog_${CHGLOG_VERSION}_linux_amd64.tar.gz | |
| cd /tmp && tar xzf git-chglog.tar.gz | |
| sudo mv git-chglog /usr/local/bin/ | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25.0' | |
| - name: Validate version format | |
| run: | | |
| if ! echo "${{ github.event.inputs.version }}" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'; then | |
| echo "Invalid version format. Must be x.y.z" | |
| exit 1 | |
| fi | |
| - name: Generate changelog | |
| run: | | |
| git-chglog --output CHANGELOG.md --next-tag "v${{ github.event.inputs.version }}" | |
| - name: Commit changelog | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "GitHub Actions" | |
| git add CHANGELOG.md | |
| git commit -m "chore: update changelog" | |
| git push | |
| - name: Create tag | |
| run: | | |
| git tag "v${{ github.event.inputs.version }}" | |
| git push origin "v${{ github.event.inputs.version }}" | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v5 | |
| with: | |
| distribution: goreleaser | |
| version: latest | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |