-
Notifications
You must be signed in to change notification settings - Fork 0
👷 Add GitHub Action for Release #3
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
Open
rickyheijnen
wants to merge
1
commit into
main
Choose a base branch
from
config/add-release-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| name: Tag Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write # Needed for tags & releases | ||
|
|
||
| concurrency: | ||
| group: tag-release-${{ github.ref }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| tag-release: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| fetch-tags: true | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Sync & prune tags | ||
| run: | | ||
| git fetch --tags --force --prune | ||
|
|
||
| - name: Determine version from composer.json | ||
| id: version | ||
| run: | | ||
| VERSION=$(jq -r '.version // empty' composer.json) | ||
| if [ -z "$VERSION" ]; then | ||
| echo "composer.json does not have a 'version' field"; exit 1 | ||
| fi | ||
|
|
||
| # prefix with 'v' if it's not already | ||
| if [[ "$VERSION" =~ ^v ]]; then | ||
| TAG="$VERSION" | ||
| else | ||
| TAG="v$VERSION" | ||
| fi | ||
|
|
||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | ||
| echo "Resolved tag: $TAG" | ||
|
|
||
| - name: Check if tag exists on origin | ||
| id: check_tag | ||
| run: | | ||
| TAG="${{ steps.version.outputs.tag }}" | ||
| if git ls-remote --tags origin | grep -q "refs/tags/${TAG}$"; then | ||
| echo "exists=true" >> "$GITHUB_OUTPUT" | ||
| echo "Tag ${TAG} already exists on origin" | ||
| else | ||
| echo "exists=false" >> "$GITHUB_OUTPUT" | ||
| echo "Tag ${TAG} does not exist on origin" | ||
| fi | ||
|
|
||
| - name: Create and push tag | ||
| if: steps.check_tag.outputs.exists == 'false' | ||
| run: | | ||
| TAG="${{ steps.version.outputs.tag }}" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
| git config --global user.name "github-actions[bot]" | ||
| git tag -a "${TAG}" -m "Version ${TAG}" | ||
| git push origin "refs/tags/${TAG}" | ||
|
|
||
| - name: Check if release exists | ||
| id: release | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| HTTP_STATUS=$(curl -sS -o /dev/null -w '%{http_code}' \ | ||
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.version.outputs.tag }}") | ||
| if [ "$HTTP_STATUS" = "200" ]; then | ||
| echo "exists=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "exists=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Create GitHub Release (autogenerated notes) | ||
| if: steps.release.outputs.exists == 'false' | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ steps.version.outputs.tag }} | ||
| name: Version ${{ steps.version.outputs.tag }} | ||
| generate_release_notes: true | ||
| allow_updates: true | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unsupported
allow_updatesinputsoftprops/action-gh-release@v2does not define anallow_updatesinput, so this step will fail at runtime with “Unexpected input 'allow_updates'” and the release will never be created.(github.com) Remove that key (the action already updates existing releases automatically) to keep the workflow green.generate_release_notes: true - allow_updates: true📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.7)
94-94: input "allow_updates" is not defined in action "softprops/action-gh-release@v2". available inputs are "append_body", "body", "body_path", "discussion_category_name", "draft", "fail_on_unmatched_files", "files", "generate_release_notes", "make_latest", "name", "prerelease", "preserve_order", "repository", "tag_name", "target_commitish", "token"
(action)
🤖 Prompt for AI Agents