diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7232f1b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +version: 2 +updates: + # Enable version updates for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "08:00" + open-pull-requests-limit: 5 + commit-message: + prefix: "ci" + include: "scope" diff --git a/.github/workflows/package-build.yml b/.github/workflows/package-build.yml new file mode 100644 index 0000000..5d5012e --- /dev/null +++ b/.github/workflows/package-build.yml @@ -0,0 +1,75 @@ +name: package-build +on: + pull_request: + push: + tags: + - 'v*' +permissions: + actions: read + contents: read + pull-requests: write +concurrency: + group: "${{ github.ref }}" + cancel-in-progress: true +jobs: + build-debian: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: "Update changelog" + run: | + set -ex + OLD_VERSION=$(dpkg-parsechangelog -SVersion) + SOURCE=$(dpkg-parsechangelog -SSource) + if [[ "${{ github.ref_type }}" == "tag" ]]; then + VERSION_SUFFIX="+gh" + else + VERSION_SUFFIX="+autobuild${GITHUB_RUN_NUMBER}" + fi + cat > debian/changelog < $(date -R) + EOT + - uses: jtdor/build-deb-action@v1 + - name: Archive build result + uses: actions/upload-artifact@v4 + with: + name: packages + if-no-files-found: error + retention-days: 14 + path: | + debian/artifacts/*.deb + debian/artifacts/*.tar.* + - name: Comment PR with artifact link + if: github.event_name == 'pull_request' + uses: actions/github-script@v8 + with: + script: | + const runId = context.runId; + const repoOwner = context.repo.owner; + const repoName = context.repo.repo; + + // Get the artifact download URL + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: repoOwner, + repo: repoName, + run_id: runId + }); + + const packagesArtifact = artifacts.data.artifacts.find(artifact => artifact.name === 'packages'); + if (!packagesArtifact) { + console.log('No packages artifact found'); + return; + } + + const artifactUrl = `https://github.com/${repoOwner}/${repoName}/actions/runs/${runId}/artifacts/${packagesArtifact.id}`; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `📦 Built packages are ready! [Download here](${artifactUrl}).` + }); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0f5f868 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,101 @@ +name: release +on: + push: + tags: + - 'v*' + +jobs: + create-release: + runs-on: ubuntu-latest + permissions: + actions: read + contents: write + steps: + - uses: actions/checkout@v5 + + - name: Extract version from tag + id: version + run: | + TAG_NAME="${GITHUB_REF#refs/tags/}" + VERSION="${TAG_NAME#v}" + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "tag=${TAG_NAME}" >> "$GITHUB_OUTPUT" + + - name: Extract changelog entry + id: changelog + run: | + VERSION="${{ steps.version.outputs.version }}" + + # Extract and clean changelog for this specific version + CHANGES=$(dpkg-parsechangelog -l debian/changelog --since "${VERSION}" --until "${VERSION}" --show-field Changes | \ + sed '/^[a-zA-Z0-9-].*([^)]*)[[:space:]]*.*$/d' | \ + sed 's/^[[:space:]]*\.[[:space:]]*$//' | \ + sed '/^[[:space:]]*$/d' | \ + sed 's/^[[:space:]]*\*[[:space:]]*/- /' | \ + sed 's/^[[:space:]]*\\+[[:space:]]*/ - /') + + # Set as output for use in release + { + echo 'description<> "$GITHUB_OUTPUT" + + - name: Wait for and get package build run ID + id: build-run + uses: actions/github-script@v8 + with: + script: | + const maxWaitTime = 10 * 60 * 1000; // 10 minutes + const pollInterval = 30 * 1000; // 30 seconds + const startTime = Date.now(); + + while (Date.now() - startTime < maxWaitTime) { + const runs = await github.rest.actions.listWorkflowRuns({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'package-build.yml', + head_sha: context.sha, + status: 'completed', + conclusion: 'success' + }); + + if (runs.data.workflow_runs.length > 0) { + const runId = runs.data.workflow_runs[0].id; + console.log(`Found successful package-build run: ${runId}`); + return runId; + } + + console.log('Package-build workflow not completed yet, waiting...'); + await new Promise(resolve => setTimeout(resolve, pollInterval)); + } + + throw new Error('Package-build workflow did not complete successfully within 10 minutes'); + + - name: Download build artifacts + uses: actions/download-artifact@v5 + with: + name: packages + path: artifacts/ + run-id: ${{ steps.build-run.outputs.result }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Create GitHub Release + run: | + DEB_FILE=$(find artifacts -name "*.deb" -printf "%f\n" | head -1) + gh release create "${{ steps.version.outputs.tag }}" \ + --title "Release ${{ steps.version.outputs.tag }}" \ + --notes "## Changes in ${{ steps.version.outputs.version }} + + ${{ steps.changelog.outputs.description }} + + --- + + 📦 **Installation:** + Download the package and install with: + \`\`\`bash + sudo apt install ./${DEB_FILE} + \`\`\`" \ + artifacts/* + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml deleted file mode 100644 index 4cc8275..0000000 --- a/.github/workflows/test-build.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: test-build -on: - pull_request: - push: - -concurrency: - group: "${{ github.ref }}" - cancel-in-progress: true -jobs: - build-debian: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: "Update changelog" - run: | - set -ex - OLD_VERSION=$(dpkg-parsechangelog -SVersion) - SOURCE=$(dpkg-parsechangelog -SSource) - cat > debian/changelog < $(date -R) - EOT - - uses: jtdor/build-deb-action@v1 - - name: Archive build result - uses: actions/upload-artifact@v4 - with: - name: deb - if-no-files-found: error - path: | - debian/artifacts/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..21a85c5 --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +# grml-paste + +[![Sponsor](https://img.shields.io/badge/Sponsor-GitHub-purple?logo=github)](https://github.com/sponsors/grml) +[![GitHub release](https://img.shields.io/github/v/release/grml/grml-paste)](https://github.com/grml/grml-paste/releases) +[![Debian package](https://img.shields.io/debian/v/grml-paste/trixie?label=debian)](https://packages.debian.org/trixie/grml-paste) +[![Ubuntu package](https://img.shields.io/ubuntu/v/grml-paste)](https://packages.ubuntu.com/search?keywords=grml-paste) + +Paste text into a pastebin service + +## Overview + +grml-paste is a client for a pastebin service like https://paste.debian.net/. + +## Installation + +### From Debian repositories + +```bash +sudo apt install grml-paste +``` + +Package information: [grml-paste on packages.debian.org](https://packages.debian.org/trixie/grml-paste) + +### From GitHub releases + +Download the latest `.deb` package from the [releases page](../../releases) and install: + +```bash +sudo apt install ./grml-paste_*.deb +``` + +## Quick start + +1. Install the package (see above) +2. Paste some text: + ```bash + echo hi | grml-paste + ``` + +## License + +This project is licensed under the GPL v2+. + +## Contributing + +- **Source code**: https://github.com/grml/grml-paste +- **Issues**: https://github.com/grml/grml-paste/issues +- **Releases**: https://github.com/grml/grml-paste/releases +- **Grml Live Linux**: https://grml.org diff --git a/grml-paste b/grml-paste index 3b84728..43ef8c6 100755 --- a/grml-paste +++ b/grml-paste @@ -1,6 +1,6 @@ #!/usr/bin/python3 # Filename: grml-paste -# Purpose: XmlRpc interface client to paste.grml.org +# Purpose: XmlRpc Pastebin interface client # Author: Michael Gebetsroither # License: This file is licensed under the GPL v2. ################################################################################ diff --git a/grml-paste.1.txt b/grml-paste.1.txt index c9bd9ff..d985136 100644 --- a/grml-paste.1.txt +++ b/grml-paste.1.txt @@ -3,7 +3,7 @@ grml-paste(1) Name ---- -grml-paste - command line interface for paste.grml.org +grml-paste - command line interface for xmlrpc pastebins Synopsis -------- @@ -12,7 +12,7 @@ grml-paste [options] ACTION Description ----------- -grml-paste is a command line interface for uploading plain text to https://paste.grml.org/ +grml-paste is a command line interface for uploading plain text to https://paste.debian.net/ Options ------- @@ -35,7 +35,7 @@ Set your nickname (defaults to login username). **-s 'server', --server='SERVER'**:: -Set URL of paste server (defaults to paste.grml.org). +Set URL of paste server (defaults to paste.debian.net). **-p, --private**::