-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add release workflow + improve image builds #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1a9920c
feat: add release workflow + improve image builds
sanbotto 28ce905
Fix VERSION file checks
sanbotto 830cd2c
Make sure new version is greater
sanbotto 9a5498f
Update actions version
sanbotto 19890ea
Pre-releases only get a single tag
sanbotto 9fe538b
Add explicit error context for git tag operations
sanbotto f16b0b2
Refactor version comparison logic in workflows to use shared action
sanbotto 317f888
Simplify run conditions
sanbotto 95276d0
Improve prerelease detection
sanbotto f510df3
Add missing id
sanbotto aee8bd0
Update action version
sanbotto 4fb990f
Fix indentation
sanbotto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| name: Create Release | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, closed] | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| version-check: | ||
| name: Check VERSION file | ||
| runs-on: ubuntu-latest | ||
| if: github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.ref == 'main' | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.ref }} | ||
|
|
||
| - name: Check VERSION file exists | ||
| run: | | ||
| if [ ! -f "VERSION" ]; then | ||
| echo "❌ VERSION file not found in repository root" | ||
| echo "Please create a VERSION file with a semantic version (e.g., v1.0.0 or 1.0.0)" | ||
| exit 1 | ||
| fi | ||
| echo "✅ VERSION file exists" | ||
|
|
||
| - name: Validate VERSION format | ||
| run: | | ||
| VERSION=$(cat VERSION | xargs) | ||
|
|
||
| # Remove 'v' prefix if present for validation | ||
| VERSION_CLEAN=${VERSION#v} | ||
|
|
||
| # Validate semantic versioning format (major.minor.patch) | ||
| if [[ ! $VERSION_CLEAN =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$ ]]; then | ||
| echo "❌ Invalid version format: $VERSION" | ||
| echo "Expected format: v1.0.0 or 1.0.0 (semantic versioning)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ Valid version: $VERSION" | ||
|
|
||
| validate-version: | ||
| name: Validate VERSION file | ||
| runs-on: ubuntu-latest | ||
| if: github.event.pull_request.merged == true && github.event.pull_request.head.repo.full_name == github.repository | ||
| outputs: | ||
| version: ${{ steps.read_version.outputs.version }} | ||
| tags: ${{ steps.generate_tags.outputs.tags }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check VERSION file exists | ||
| id: check_version_file | ||
| run: | | ||
| if [ ! -f "VERSION" ]; then | ||
| echo "❌ VERSION file not found in repository root" | ||
| exit 1 | ||
| fi | ||
| echo "✅ VERSION file exists" | ||
|
|
||
| - name: Read and validate VERSION | ||
| id: read_version | ||
| shell: bash | ||
| run: | | ||
| VERSION=$(cat VERSION | xargs) | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| # Remove 'v' prefix if present for validation | ||
| VERSION_CLEAN=${VERSION#v} | ||
|
|
||
| # Validate semantic versioning format (major.minor.patch) | ||
| if [[ ! $VERSION_CLEAN =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$ ]]; then | ||
| echo "❌ Invalid version format: $VERSION" | ||
| echo "Expected format: v1.0.0 or 1.0.0 (semantic versioning)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ Valid version: $VERSION" | ||
|
|
||
| - name: Generate tags | ||
| id: generate_tags | ||
| shell: bash | ||
| run: | | ||
| VERSION="${{ steps.read_version.outputs.version }}" | ||
| # Remove 'v' prefix if present for parsing | ||
| VERSION_CLEAN=${VERSION#v} | ||
|
|
||
| # Extract major, minor, patch | ||
| IFS='.' read -ra VERSION_PARTS <<< "$VERSION_CLEAN" | ||
| MAJOR=${VERSION_PARTS[0]} | ||
| MINOR=${VERSION_PARTS[1]} | ||
| PATCH=${VERSION_PARTS[2]%%-*} # Remove pre-release suffix if present | ||
| PATCH=${PATCH%%+*} # Remove build metadata if present | ||
|
|
||
| # Ensure full version has 'v' prefix for consistency | ||
| if [[ "$VERSION" == v* ]]; then | ||
| VERSION_TAG="$VERSION" | ||
| else | ||
| VERSION_TAG="v${VERSION}" | ||
| fi | ||
|
|
||
| # Generate tags: latest, v{major}, v{major}.{minor}, v{full} | ||
| TAGS="latest,v${MAJOR},v${MAJOR}.${MINOR},${VERSION_TAG}" | ||
|
|
||
| echo "tags=$TAGS" >> $GITHUB_OUTPUT | ||
| echo "Generated tags: $TAGS" | ||
|
|
||
| create-release: | ||
| name: Create GitHub Release | ||
| runs-on: ubuntu-latest | ||
| needs: validate-version | ||
| if: github.event.pull_request.merged == true && github.event.pull_request.head.repo.full_name == github.repository | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Create Git Tag | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| VERSION="${{ needs.validate-version.outputs.version }}" | ||
| git tag -a "$VERSION" -m "Release $VERSION" | ||
| git push origin "$VERSION" | ||
|
|
||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ needs.validate-version.outputs.version }} | ||
| name: Release ${{ needs.validate-version.outputs.version }} | ||
| body: | | ||
| Release ${{ needs.validate-version.outputs.version }} | ||
|
|
||
| Merged from PR #${{ github.event.pull_request.number }} | ||
| draft: false | ||
| prerelease: false | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Trigger build workflow | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const tags = '${{ needs.validate-version.outputs.tags }}'; | ||
| await github.rest.actions.createWorkflowDispatch({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| workflow_id: 'build-and-push-images.yaml', | ||
| ref: 'main', | ||
| inputs: { | ||
| tag: tags | ||
| } | ||
| }); | ||
| console.log(`Triggered build workflow with tags: ${tags}`); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.