Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 60 additions & 7 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Placeholder draft-release workflow
# Drafts new mailtrap-php release: computes the next version from the latest GitHub release,
# regenerates the changelog from merged PRs, and opens a release PR against main.
#
name: Draft php Release
# Packagist derives the version from the git tag
# Tags are bare semver (X.Y.Z)
name: Draft PHP Release
on:
workflow_dispatch:
inputs:
Expand All @@ -14,14 +17,64 @@ on:
- major
default: patch

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

permissions:
contents: write
pull-requests: write

jobs:
draft-release:
name: Draft php Release (placeholder)
name: Draft mailtrap-php Release
runs-on: ubuntu-latest
steps:
- name: Echo inputs
- uses: actions/checkout@v4
with:
ref: main

- name: Read current version from latest release
id: read
env:
BUMP_TYPE: ${{ inputs.bump_type }}
GH_TOKEN: ${{ github.token }}
run: |
echo "Placeholder draft-release workflow"
echo "bump_type=$BUMP_TYPE"
latest=$(gh api "repos/$GITHUB_REPOSITORY/releases/latest" --jq '.tag_name')
echo "version=${latest#v}" >> "$GITHUB_OUTPUT"
Comment on lines +42 to +43

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the workflow around the cited lines
cat -n .github/workflows/draft-release.yml | sed -n '1,120p'

# Find any references to compute-next-semver in the repo
rg -n "compute-next-semver|releases/latest|latest release|version=" .github/workflows . -g '!node_modules'

Repository: mailtrap/mailtrap-php

Length of output: 3764


🌐 Web query:

GitHub API releases/latest draft prerelease excluded no published release 404 compute-next-semver empty current input

💡 Result:

The GitHub API endpoint GET /repos/{owner}/{repo}/releases/latest is designed to return the most recent non-prerelease, non-draft release [1][2][3]. If a repository has only draft or prerelease releases, or no releases at all, this endpoint will return a 404 Not Found error [2][4][5]. This occurs because the endpoint specifically ignores drafts and prereleases when determining the "latest" version [1][2][6]. Key behaviors and technical details: - Definition of Latest: The "latest" release is strictly defined as the most recent published full release, sorted by the created_at attribute [1][3]. - API 404: The 404 response is the standard behavior when the criteria for a "latest" release are not met [4]. While some official documentation may not explicitly list 404 as a potential response code, it is widely documented as the expected behavior for repositories lacking stable, published releases [4]. - Prerelease/Draft Exclusion: These release types are intentionally excluded from this specific endpoint [1][5]. They cannot be set as the "latest" release via the API's make_latest parameter [1][3]. - Handling 404s: Developers relying on this endpoint for automated tooling (like version resolvers) must implement handling for the 404 error, typically by falling back to listing all releases and manually parsing tags to find the latest available version [2][7]. For scenarios where you need to support prereleases or drafts, you should avoid /releases/latest and instead use the /repos/{owner}/{repo}/releases endpoint to list all releases and filter them programmatically [2].

Citations:


🌐 Web query:

railsware/github-actions compute-next-semver empty current input default initial version

💡 Result:

The railsware/github-actions repository contains a collection of utility actions [1], but there is no widely documented or specialized GitHub Action named compute-next-semver within that specific organization [2][3][1]. It is highly likely that the action you are referring to is a different project—such as MiguelRipoll23/get-next-version [4], mirceanton/action-semver-metadata [5], or lhstrh/action-repo-semver [6]—which are commonly used to compute semantic versions and handle initial version inputs. If you are encountering issues with "empty" inputs for initial versions in such GitHub Actions: 1. Handling of Empty Inputs: In GitHub Actions, if a workflow input is empty, it does not automatically revert to a default value unless the action logic explicitly checks for an empty string and applies a fallback [4][7]. 2. Default Behavior: Most well-designed semver actions (like mirceanton/action-semver-metadata [5] or lhstrh/action-repo-semver [6]) have explicit input fields (e.g., default-version) to handle the case where no previous release exists. 3. Troubleshooting: - Verify the exact repository name you are using. - Check the action.yml file of the specific action for an input parameter named something like default-initial-version, initial-version, or default-version [4][5][6]. - Ensure you are providing this input in your workflow if you do not want to rely on the hardcoded default (which is often 0.0.0 or 1.0.0) [5][6]. If you are using a custom or private action, you may need to update its logic to check if the input is empty or null and provide a default accordingly [4].

Citations:


🌐 Web query:

site:github.com/railsware/github-actions compute-next-semver action.yml current input default empty

💡 Result:

Based on the provided search results, there is no widely recognized GitHub Action named exactly compute-next-semver. Several similar tools exist, such as allegro-actions/next-version [1], fabien-marty/github-next-semantic-version [2], and other CLI-based tools like git-semver [3] and next-ver [4]. In the context of GitHub Actions, inputs defined in an action.yml file that are left empty or omitted by the user behave according to the default value specified in the configuration. If a default is defined as an empty string or not provided, the input will hold an empty value within the action's execution environment. For example, in the documentation for github-next-semantic-version, specific options like --must-have-labels explicitly note that "empty => no filtering" [2]. If you are working with a specific custom action, you should check its action.yml file to see how the default property is defined for each input.

Citations:


Handle the no-published-release case in draft-release.yml

GET /repos/$GITHUB_REPOSITORY/releases/latest returns 404 until the repo has a published release, and this workflow only creates drafts. Seed an initial version or fall back cleanly here so the first draft release doesn’t fail.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/draft-release.yml around lines 42 - 43, The release
version lookup in the draft-release workflow fails before any published release
exists because the `gh api ... releases/latest` call returns 404. Update the
version-seeding logic around the `latest`/`GITHUB_OUTPUT` step to handle the
no-published-release case gracefully, either by falling back to a default
initial version or by detecting the 404 and using a safe starting version so the
draft release can still be created.


- name: Compute next version
id: bump
uses: railsware/github-actions/compute-next-semver@master
with:
current: ${{ steps.read.outputs.version }}
bump-type: ${{ inputs.bump_type }}

- name: Generate release notes
id: notes
uses: railsware/github-actions/generate-release-notes@master
with:
tag: ${{ steps.bump.outputs.next }}

- name: Prepend new section to CHANGELOG.md
if: steps.notes.outputs.release_notes != ''
uses: railsware/github-actions/prepend-changelog@master
with:
version: ${{ steps.bump.outputs.next }}
release-notes: ${{ steps.notes.outputs.release_notes }}

- name: Commit, push, open PR
if: steps.notes.outputs.release_notes != ''
uses: railsware/github-actions/open-sdk-release-pr@master
with:
tag: ${{ steps.bump.outputs.next }}
current: ${{ steps.read.outputs.version }}
next: ${{ steps.bump.outputs.next }}
bump-type: ${{ inputs.bump_type }}
release-notes: ${{ steps.notes.outputs.release_notes }}

- name: Create draft GitHub release
if: steps.notes.outputs.release_notes != ''
uses: railsware/github-actions/create-draft-github-release@master
with:
tag: ${{ steps.bump.outputs.next }}
release-notes: ${{ steps.notes.outputs.release_notes }}
Loading