-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70764ee
commit 691776e
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,62 @@ | ||
name: Update Packagist | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
selected_tag: | ||
description: 'Tag to use' | ||
required: false | ||
push: | ||
tags: | ||
- '*' # This matches all tag pushes | ||
|
||
jobs: | ||
fetch-tags: | ||
if: github.event_name == 'workflow_dispatch' # Only run when triggered manually | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tags: ${{ steps.get-tags.outputs.tag-list }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get Tags | ||
id: get-tags | ||
run: | | ||
tags=$(git tag --sort=-v:refname | head -n 10) # Fetch the 10 most recent tags | ||
echo "Fetched tags:" | ||
echo "$tags" | ||
echo "::set-output name=tag-list::$tags" | ||
- name: Print Tags for User | ||
run: | | ||
echo "Here are the latest tags:" | ||
echo "${{ steps.get-tags.outputs.tag-list }}" | ||
update-packagist: | ||
runs-on: ubuntu-latest | ||
needs: fetch-tags | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Determine Tag to Use | ||
id: determine-tag | ||
run: | | ||
if [ "${{ github.event_name }}" == "push" ]; then | ||
# Extract the tag name from the push event | ||
TAG_NAME="${GITHUB_REF##*/}" | ||
echo "Pushed tag: $TAG_NAME" | ||
echo "::set-output name=tag::$TAG_NAME" | ||
else | ||
# Use the manually selected tag | ||
echo "Manually selected tag: ${{ github.event.inputs.selected_tag }}" | ||
echo "::set-output name=tag::${{ github.event.inputs.selected_tag }}" | ||
fi | ||
- name: Trigger Packagist update | ||
run: | | ||
echo "Updating Packagist for tag ${{ steps.determine-tag.outputs.tag }}" | ||
curl -X POST "https://packagist.org/api/update-package?username=env.PACKAGIST_USERNAME&apiToken=${{ secrets.PACKAGIST_API_TOKEN }}&tag=${{ steps.determine-tag.outputs.tag }}" | ||
env: | ||
PACKAGIST_API_TOKEN: ${{ secrets.PACKAGIST_API_TOKEN }} |