Skip to content

Commit

Permalink
move to my own apt repo
Browse files Browse the repository at this point in the history
  • Loading branch information
cdzombak committed Oct 15, 2023
1 parent be03080 commit c86436c
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 57 deletions.
89 changes: 47 additions & 42 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ env:
FPM_VERSION: 1.15.1

jobs:

meta:
name: Derive Build Metadata
runs-on: ubuntu-latest
Expand All @@ -29,7 +28,7 @@ jobs:
id: bin_version
run: echo "bin_version=$(./.version.sh)" >> "$GITHUB_OUTPUT"
- name: bin_version
run: 'echo bin_version: ${{ steps.bin_version.outputs.bin_version }}'
run: "echo bin_version: ${{ steps.bin_version.outputs.bin_version }}"
- name: Check if this is a running version tag update
id: running_version_tag
run: |
Expand All @@ -43,33 +42,32 @@ jobs:
echo "is_running_version_tag_update=false" >> "$GITHUB_OUTPUT"
fi
- name: is_running_version_tag
run: 'echo is_running_version_tag_update: ${{ steps.running_version_tag.outputs.is_running_version_tag_update }}'
run: "echo is_running_version_tag_update: ${{ steps.running_version_tag.outputs.is_running_version_tag_update }}"
outputs:
# nb. homebrew-releaser assumes the program name is == the repository name
bin_name: ${{ github.event.repository.name }}
bin_version: ${{ steps.bin_version.outputs.bin_version }}
packagecloud_owner: ${{ github.repository_owner }}
packagecloud_repo: oss
is_prerelease: >-
${{
steps.running_version_tag.outputs.is_running_version_tag_update != 'true' &&
startsWith(github.ref, 'refs/tags/v') &&
(contains(github.ref, '-alpha.')
|| contains(github.ref, '-beta.')
|| contains(github.ref, '-rc.'))
}}
${{
steps.running_version_tag.outputs.is_running_version_tag_update != 'true' &&
startsWith(github.ref, 'refs/tags/v') &&
(contains(github.ref, '-alpha.')
|| contains(github.ref, '-beta.')
|| contains(github.ref, '-rc.'))
}}
is_release: >-
${{
steps.running_version_tag.outputs.is_running_version_tag_update != 'true' &&
startsWith(github.ref, 'refs/tags/v') &&
!(contains(github.ref, '-alpha.')
|| contains(github.ref, '-beta.')
|| contains(github.ref, '-rc.'))
}}
${{
steps.running_version_tag.outputs.is_running_version_tag_update != 'true' &&
startsWith(github.ref, 'refs/tags/v') &&
!(contains(github.ref, '-alpha.')
|| contains(github.ref, '-beta.')
|| contains(github.ref, '-rc.'))
}}
is_pull_request: ${{ github.event_name == 'pull_request' }}
is_running_version_tag_update: ${{ steps.running_version_tag.outputs.is_running_version_tag_update }}


lint:
name: Lint
runs-on: ubuntu-latest
Expand All @@ -95,7 +93,6 @@ jobs:
megalinter-reports
mega-linter.log
binaries:
name: Binaries & Debian Packages
needs: [lint, meta]
Expand All @@ -116,7 +113,7 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
ruby-version: "3.2"
bundler-cache: true
- name: Ruby version
run: ruby --version
Expand All @@ -138,13 +135,12 @@ jobs:
name: ${{ needs.meta.outputs.bin_name }} Binary Artifacts
path: out/gh-release/*


release:
name: GitHub (Pre)Release
needs: [meta, binaries]
if: >-
needs.meta.outputs.is_release == 'true' ||
needs.meta.outputs.is_prerelease == 'true'
needs.meta.outputs.is_release == 'true' ||
needs.meta.outputs.is_prerelease == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -165,7 +161,6 @@ jobs:
fail_on_unmatched_files: true
generate_release_notes: true


tags:
name: Update Release Tags
needs: [meta, release]
Expand All @@ -183,15 +178,12 @@ jobs:
create-release: false
update-full-release: false



packagecloud:
name: PackageCloud
aptly:
name: Aptly
needs: [meta, binaries]
if: needs.meta.outputs.is_release == 'true'
runs-on: ubuntu-latest
steps:

- name: Download binaries & packages
uses: actions/download-artifact@v3
with:
Expand All @@ -201,19 +193,32 @@ jobs:
run: ls -R
working-directory: out

- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: Login to Tailscale
uses: tailscale/github-action@v2
with:
ruby-version: '3.2'
bundler-cache: true
- name: Ruby version
run: ruby --version
- name: Install PackageCloud CLI
run: |
gem install --no-document package_cloud
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:github-actions

- name: Push to PackageCloud
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Push to Aptly Repo
shell: bash
run: |
set -x
for DEB in out/*.deb; do
curl -u "${{ secrets.APTLY_CRED }}" \
-fsS -X POST \
-F file=@"${DEB}" \
"${{ secrets.APTLY_API }}/files/${{ needs.meta.outputs.bin_name }}-${{ needs.meta.outputs.bin_version }}"
done
curl -u "${{ secrets.APTLY_CRED }}" \
-fsS -X POST \
"${{ secrets.APTLY_API }}/repos/${{ needs.meta.outputs.aptly_repo_name }}/file/${{ needs.meta.outputs.bin_name }}-${{ needs.meta.outputs.bin_version }}?forceReplace=1"
- name: Update Published Aptly Repo
run: |
package_cloud push --yes ${{ needs.meta.outputs.packagecloud_owner }}/${{ needs.meta.outputs.packagecloud_repo }}/any/any out/*.deb
set -x
curl -u "${{ secrets.APTLY_CRED }}" \
-fsS -X PUT \
-H 'Content-Type: application/json' \
--data '{"ForceOverwrite": true}' \
"${{ secrets.APTLY_API }}/publish/${{ needs.meta.outputs.aptly_publish_prefix }}/${{ needs.meta.outputs.aptly_dist }}?_async=true"
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,28 @@ RUNNER_OUTFD_STDERR=2

## Installation

### Debian via PackageCloud
### Debian via apt repository

Install my Debian repository if you haven't already:

Install my PackageCloud Debian repository if you haven't already:
```shell
curl -s https://packagecloud.io/install/repositories/cdzombak/oss/script.deb.sh?any=true | sudo bash
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://dist.cdzombak.net/deb.key | sudo gpg --dearmor -o /etc/apt/keyrings/dist-cdzombak-net.gpg
sudo chmod 0644 /etc/apt/keyrings/dist-cdzombak-net.gpg
echo -e "deb [signed-by=/etc/apt/keyrings/dist-cdzombak-net.gpg] https://dist.cdzombak.net/deb/oss any oss\n" | sudo tee -a /etc/apt/sources.list.d/dist-cdzombak-net.list > /dev/null
sudo apt-get update
```

Then install `runner` via `apt-get`:

```shell
sudo apt-get install runner
```

### Manual installation from build artifacts

Pre-built binaries for Linux and macOS on various architectures are downloadable from each [GitHub Release](https://github.com/cdzombak/runner/releases). Debian packages for each release are available as well.
Pre-built binaries for Linux and macOS on various architectures are downloadable from each [GitHub Release](https://github.com/cdzombak/runner/releases). Debian packages for each release are available as well.

### Build and install locally

Expand Down Expand Up @@ -81,7 +88,7 @@ If you plan to use the `RUNNER_OUTFD_PID` and `RUNNER_OUTFD_STD[OUT|ERR]` variab
- `-hide-env`: Hide the process's environment, which is normally printed & logged as part of the output.
- `-job-name string`: Job name used in failure notifications and log file name. (default: program name, without path)
- `-log-dir string`: The directory to write run logs to.
- Can also be set by the `RUNNER_LOG_DIR` environment variable; this flag overrides the environment variable.
- Can also be set by the `RUNNER_LOG_DIR` environment variable; this flag overrides the environment variable.
- `-print-if-match value`: Print/mail output if the given (**case-sensitive**) string appears in the program's output, even if it was a healthy exit. May be specified multiple times.
- `-print-if-not-match value`: Print/mail output if the given (**case-sensitive**) string does not appear in the program's output, even if it was a healthy exit. May be specified multiple times.
- `-retries int`: If the command fails, retry it this many times.
Expand All @@ -92,27 +99,27 @@ If you plan to use the `RUNNER_OUTFD_PID` and `RUNNER_OUTFD_STD[OUT|ERR]` variab
- `RUNNER_HIDE_ENV` (environment variable only): Colon-separated list of environment variables which will be entirely omitted from output.

#### Run as another user

- `-gid int`: Run the program as the given GID. Ignored on Windows. (If provided, runner must be run as `root` or with `CAP_SETGID`.)
- `-uid int`: Run the program as the given UID. Ignored on Windows. (If provided, runner must be run as `root` or with `CAP_SETUID`.)
- `-user string`: Run the program as the given user. Ignored on Windows. (If provided, runner must be run as `root` or with `CAP_SETUID` and `CAP_SETGID`.)

#### Email options

- `-mail-from string`: The email address to use as the `From:` address in failure emails. (default: `runner@hostname`)
- Can also be set by the `RUNNER_MAIL_FROM` environment variable; this flag overrides the environment variable.
- Can also be set by the `RUNNER_MAIL_FROM` environment variable; this flag overrides the environment variable.
- `-mail-tab-char string`: Replace tab characters in emailed output by this string.
- Can also be set by the `RUNNER_MAIL_TAB_CHAR` environment variable; this flag overrides the environment variable.
- Can also be set by the `RUNNER_MAIL_TAB_CHAR` environment variable; this flag overrides the environment variable.
- `-mailto string`: Send an email to the given address if the program fails or its output would otherwise be printed per `-healthy-exit`/`-print-if-[not]-match`/`-always-print`.
- Can also be set by the `MAILTO` environment variable; this flag overrides the environment variable.
- Can also be set by the `MAILTO` environment variable; this flag overrides the environment variable.
- `-smtp-host string`: SMTP server hostname.
- Can also be set by the `RUNNER_SMTP_HOST` environment variable; this flag overrides the environment variable.
- Can also be set by the `RUNNER_SMTP_HOST` environment variable; this flag overrides the environment variable.
- `-smtp-pass string`: Password for SMTP authentication.
- Can also be set by the `RUNNER_SMTP_PASS` environment variable; this flag overrides the environment variable.
- Can also be set by the `RUNNER_SMTP_PASS` environment variable; this flag overrides the environment variable.
- `-smtp-port int`: SMTP server port.
- Can also be set by the `RUNNER_SMTP_PORT` environment variable; this flag overrides the environment variable. (default: 25)
- Can also be set by the `RUNNER_SMTP_PORT` environment variable; this flag overrides the environment variable. (default: 25)
- `-smtp-user string`: Username for SMTP authentication.
- Can also be set by the `RUNNER_SMTP_USER` environment variable; this flag overrides the environment variable.
- Can also be set by the `RUNNER_SMTP_USER` environment variable; this flag overrides the environment variable.

### Sample Output

Expand Down Expand Up @@ -148,7 +155,7 @@ Schedule a cleanup job to run daily via cron:
```text
RUNNER_LOG_DIR="/home/myusername/log/runner"
# ...
0 0 * * * /usr/bin/find "$RUNNER_LOG_DIR" -mtime +30 -name "*.log" -delete
0 0 * * * /usr/bin/find "$RUNNER_LOG_DIR" -mtime +30 -name "*.log" -delete
```

This will remove logs older than 30 days.
Expand All @@ -157,7 +164,7 @@ This will remove logs older than 30 days.

- Issues: https://github.com/cdzombak/runner/issues/new
- Author: [Chris Dzombak](https://www.dzombak.com)
- [GitHub: @cdzombak](https://www.github.com/cdzombak)
- [GitHub: @cdzombak](https://www.github.com/cdzombak)

## License

Expand Down

0 comments on commit c86436c

Please sign in to comment.