diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ba4192..d6061b8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,12 +33,21 @@ jobs: - uses: ./action/package id: package with: - name: blank-sinatra-app target: ${{ matrix.target }} + name: blank-sinatra-app version: '1.0.0' path: app + debug: true - name: Upload uses: actions/upload-artifact@v4 with: name: ${{ steps.package.outputs.package_name }} - path: ${{ steps.package.outputs.package_path }} \ No newline at end of file + 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 }} \ No newline at end of file diff --git a/package/action.yml b/package/action.yml index ec852eb..2430b83 100644 --- a/package/action.yml +++ b/package/action.yml @@ -24,6 +24,14 @@ inputs: description: 'Prefix for the cache' required: true default: 'v1' + env: + description: 'Environment variables to pass to pkgr' + required: false + default: '' + debug: + description: 'Debug mode' + required: false + default: 'false' outputs: workspace: @@ -68,6 +76,7 @@ runs: with: path: ${{ steps.setup.outputs.workspace }}/cache key: pkgr-${{ inputs.cache_prefix }}-${{ inputs.target }}-${{ inputs.pkgr_version }} + save-always: true - name: Package shell: bash @@ -80,8 +89,9 @@ runs: -v .:/pkgr/app \ -v $workspace/cache:/pkgr/cache \ -v $workspace/output:/pkgr/output \ + --net=host \ ghcr.io/crohr/pkgr/${{ inputs.target }}-${{ inputs.pkgr_version }} \ - --name "${{ inputs.name }}" --version "${{ inputs.version }}" --iteration "${{ steps.setup.outputs.iteration }}" + --name "${{ inputs.name }}" --version "${{ inputs.version }}" --iteration "${{ steps.setup.outputs.iteration }}" --env "${{ inputs.env }}" --debug=${{ inputs.debug }} package_path="" if [ -f $workspace/output/*.deb ]; then diff --git a/publish/action.yml b/publish/action.yml new file mode 100644 index 0000000..0884c57 --- /dev/null +++ b/publish/action.yml @@ -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 }}" \ No newline at end of file