Skip to content

Commit

Permalink
GH action for packagist update
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminJoergerMakaira committed Nov 15, 2024
1 parent 70764ee commit 691776e
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/updatePackagist.yaml
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 }}

0 comments on commit 691776e

Please sign in to comment.