Skip to content
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

Add action to publish package #1

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ jobs:
- uses: ./action/package
id: package
with:
name: blank-sinatra-app
target: ${{ matrix.target }}
name: blank-sinatra-app
version: '1.0.0'
path: app
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ steps.package.outputs.package_name }}
path: ${{ steps.package.outputs.package_path }}
path: ${{ steps.package.outputs.package_path }}
- name: Publish
uses: ./action/publish
with:
target: ${{ matrix.target }}
token: ${{ secrets.PUBLISH_TOKEN }}
repository: crohr/blank-sinatra-app
channel: master
artefact: ${{ steps.package.outputs.package_path }}
50 changes: 50 additions & 0 deletions publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'pkgr/action/publish'
description: 'Publish your package to the packagehall'
inputs:
artefact:
description: 'Artefact to publish'
required: true
target:
description: 'Distribution'
required: true
repository:
description: 'Repository to publish to'
required: true
default: '${{ github.repository }}'
channel:
description: 'Channel to publish to'
required: true
default: 'master'
token:
description: 'Token to use for authentication'
required: true
force:
description: 'Publish even if the artefact already exists, and auto-create the channel if it does not exist'
required: false
default: "true"

outputs:
id:
description: "Package identifier"
value: ${{ steps.upload.outputs.id }}

runs:
using: "composite"
steps:
- name: Upload
id: upload
shell: bash
env:
REPO_FULL_NAME: ${{ inputs.repository }}
TARGET: ${{ inputs.target }}
CHANNEL: ${{ inputs.channel }}
run: |
org="${REPO_FULL_NAME%%/*}"
repo="${REPO_FULL_NAME##*/}"
url="https://dl.packager.io/api/orgs/${org}/repos/${repo}/packages"
echo "Pushing to ${url}..."
curl --fail-with-body -u "${{ inputs.token }}" -i -X POST "${url}" \
-F "artefact=@${{ inputs.artefact }}" \
-F "targets[]=${TARGET/://}" \
-F "channels[]=$CHANNEL" \
-F "force=${{ inputs.force }}"