Create Release #19
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: Create Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: 'Source branch' | |
| required: true | |
| type: choice | |
| options: | |
| - main | |
| - mainnet-alpha-beta | |
| version: | |
| description: 'Release version (e.g., v1.0.0, v2.0.0-beta.1)' | |
| required: true | |
| type: string | |
| release_notes: | |
| description: 'Release notes' | |
| required: false | |
| type: string | |
| default: '' | |
| jobs: | |
| create-release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.branch }} | |
| - name: Verify version matches .version.json | |
| run: | | |
| # Read version from .version.json | |
| VERSION_FILE="pkg/version/.version.json" | |
| if [ ! -f "$VERSION_FILE" ]; then | |
| echo "Error: $VERSION_FILE not found" | |
| exit 1 | |
| fi | |
| # Extract version from JSON file | |
| JSON_VERSION=$(grep -o '"version"[[:space:]]*:[[:space:]]*"[^"]*"' "$VERSION_FILE" | sed 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/') | |
| # Remove 'v' prefix from input version if present for comparison | |
| INPUT_VERSION="${{ inputs.version }}" | |
| INPUT_VERSION_NO_V="${INPUT_VERSION#v}" | |
| # Check if versions match (comparing without 'v' prefix) | |
| if [ "$JSON_VERSION" != "$INPUT_VERSION_NO_V" ]; then | |
| echo "Error: Version mismatch!" | |
| echo " Release version: $INPUT_VERSION_NO_V" | |
| echo " .version.json: $JSON_VERSION" | |
| echo "" | |
| echo "Please update $VERSION_FILE to match the release version before creating a release." | |
| exit 1 | |
| fi | |
| echo "Version check passed: $JSON_VERSION" | |
| - name: Create tag | |
| run: | | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git tag -a ${{ inputs.version }} -m "Release ${{ inputs.version }}" | |
| git push origin ${{ inputs.version }} | |
| - name: Determine if prerelease | |
| id: prerelease | |
| run: | | |
| # main branch releases are prereleases | |
| # mainnet-alpha-beta releases are stable | |
| if [[ "${{ inputs.branch }}" == "main" ]]; then | |
| echo "is_prerelease=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_prerelease=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.version }} | |
| name: ${{ inputs.version }} | |
| body: ${{ inputs.release_notes }} | |
| draft: false | |
| prerelease: ${{ steps.prerelease.outputs.is_prerelease }} | |
| generate_release_notes: true | |
| build-test-push: | |
| uses: ./.github/workflows/docker-build.yml | |
| with: | |
| tag: ${{ inputs.version }} | |
| ref: ${{ inputs.version }} | |
| push: true | |
| secrets: inherit | |
| publish-to-buf: | |
| needs: create-release | |
| uses: ./.github/workflows/buf-publish.yml | |
| with: | |
| label: ${{ inputs.version }} | |
| secrets: inherit |