Skip to content

Commit

Permalink
WIP: publish kentik agent package
Browse files Browse the repository at this point in the history
  • Loading branch information
Will committed Sep 4, 2024
1 parent dc5fe64 commit 9308144
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 70 deletions.
31 changes: 31 additions & 0 deletions .github/actions/bundle/action.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as io from '@actions/io';

let binary = process.env.BINARY;
let version = process.env.VERSION;

let [name, arch, _, os] = binary.split('-');

switch (arch) {
case 'aarch64':
arch = 'arm64';
break;
case 'armv7':
arch = 'arm';
break;
case 'x86_64':
arch = 'amd64';
break;
}

let bundle = `${name}_${version}_${os}_${arch}.tgz`;
let prefix = `${name}-${version}`;

let dir = `${prefix}/bin`;
await io.mkdirP(dir);
await io.cp(name, `${dir}/${name}`);

await exec.exec(`tar -czvf ${bundle} ${prefix}`);

core.setOutput('bundle', bundle);
35 changes: 35 additions & 0 deletions .github/actions/bundle/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: bundle

inputs:
artifact:
required: true
version:
required: true

outputs:
bundle:
value: ${{ steps.bundle.outputs.bundle }}

runs:
using: composite
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact }}
- run: ls -lR
shell: bash
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install $GITHUB_ACTION_PATH
shell: bash
- run: node $GITHUB_ACTION_PATH/action.mjs
env:
BINARY: ${{ inputs.artifact }}
VERSION: ${{ inputs.version }}
shell: bash
id: bundle
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.bundle.outputs.bundle }}
path: ${{ steps.bundle.outputs.bundle }}
10 changes: 10 additions & 0 deletions .github/actions/bundle/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "bundle",
"type": "module",
"version": "0.0.1",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3"
}
}
34 changes: 34 additions & 0 deletions .github/actions/package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: package

inputs:
artifact:
required: true
version:
required: true
arch:
required: true
format:
required: true

outputs:
bundle:
value: ${{ steps.bundle.outputs.bundle }}

runs:
using: composite
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact }}
- uses: kentik/pkg@master
with:
name: ${{ github.event.repository.name }}
version: ${{ inputs.version }}
arch: ${{ inputs.arch }}
format: ${{ inputs.format }}
package: package.yml
id: package
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.package.outputs.package }}
path: ${{ steps.package.outputs.package }}
158 changes: 88 additions & 70 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,41 @@ jobs:
- x86_64-unknown-freebsd
continue-on-error: ${{ !startsWith(matrix.target, 'x86_64') }}
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.KENTIK_API_RUST_DEPLOY_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
# target: ${{ matrix.target }}
# - uses: webfactory/[email protected]
# with:
# ssh-private-key: ${{ secrets.KENTIK_API_RUST_DEPLOY_KEY }}
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - run: |
# DOCKER_OPTS="-v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent"
# echo DOCKER_OPTS="$DOCKER_OPTS" >> $GITHUB_ENV
# - uses: docker/build-push-action@v4
# with:
# context: .github/workflows
# file: .github/workflows/Dockerfile.${{ matrix.target }}
# tags: local/cross:${{ matrix.target }}
# push: false
# env:
# DOCKER_BUILDKIT: 1
# - uses: actions-rs/cargo@v1
# with:
# use-cross: true
# command: build
# args: --release --target ${{ matrix.target }}


- run: |
DOCKER_OPTS="-v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent"
echo DOCKER_OPTS="$DOCKER_OPTS" >> $GITHUB_ENV
- uses: docker/build-push-action@v4
with:
context: .github/workflows
file: .github/workflows/Dockerfile.${{ matrix.target }}
tags: local/cross:${{ matrix.target }}
push: false
env:
DOCKER_BUILDKIT: 1
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}
mkdir -p target/${{ matrix.target }}/release
touch target/${{ matrix.target }}/release/kprobe
shell: bash
- uses: actions/upload-artifact@v4
with:
name: kprobe-${{ matrix.target }}
Expand Down Expand Up @@ -73,6 +81,24 @@ jobs:
name: version
path: version

bundle:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- armv7-unknown-linux-musleabihf
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/bundle
with:
artifact: kprobe-${{ matrix.target }}
version: ${{ needs.version.outputs.version }}
needs: [build, version]

package:
runs-on: ubuntu-latest
strategy:
Expand All @@ -90,59 +116,51 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: kprobe-${{ matrix.target.name }}
- id: package
uses: kentik/pkg@master
- uses: ./.github/actions/package
with:
name: ${{ github.event.repository.name }}
artifact: kprobe-${{ matrix.target.name }}
version: ${{ needs.version.outputs.version }}
arch: ${{ matrix.target.arch }}
format: ${{ matrix.format }}
package: package.yml
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.package.outputs.package }}
path: ${{ steps.package.outputs.package }}
needs: [build, version]

publish-packages:
runs-on: ubuntu-latest
steps:
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- uses: actions/download-artifact@v4
with:
path: packages
- name: publish packages
run: |
ls -ltR packages
# publish-packages:
# runs-on: ubuntu-latest
# steps:
# - uses: ruby/setup-ruby@v1
# with:
# ruby-version: 2.7
# - uses: actions/download-artifact@v4
# with:
# path: packages
# - name: publish packages
# run: |
# ls -ltR packages

gem install package_cloud
# gem install package_cloud

case "${{ startsWith(github.ref, 'refs/tags') }}" in
true) REPO="${{ github.event.repository.name }}" ;;
false) REPO="${{ github.event.repository.name }}-dev" ;;
esac
# case "${{ startsWith(github.ref, 'refs/tags') }}" in
# true) REPO="${{ github.event.repository.name }}" ;;
# false) REPO="${{ github.event.repository.name }}-dev" ;;
# esac

for deb in packages/*.deb/*.deb; do
package_cloud push kentik/$REPO/debian/jessie $deb
package_cloud push kentik/$REPO/debian/stretch $deb
package_cloud push kentik/$REPO/debian/buster $deb
package_cloud push kentik/$REPO/debian/bullseye $deb
# for deb in packages/*.deb/*.deb; do
# package_cloud push kentik/$REPO/debian/jessie $deb
# package_cloud push kentik/$REPO/debian/stretch $deb
# package_cloud push kentik/$REPO/debian/buster $deb
# package_cloud push kentik/$REPO/debian/bullseye $deb

package_cloud push kentik/$REPO/ubuntu/focal $deb
package_cloud push kentik/$REPO/ubuntu/bionic $deb
package_cloud push kentik/$REPO/ubuntu/jammy $deb
done
# package_cloud push kentik/$REPO/ubuntu/focal $deb
# package_cloud push kentik/$REPO/ubuntu/bionic $deb
# package_cloud push kentik/$REPO/ubuntu/jammy $deb
# done

for rpm in packages/*.rpm/*.rpm; do
package_cloud push kentik/$REPO/el/7 $rpm
package_cloud push kentik/$REPO/el/8 $rpm
package_cloud push kentik/$REPO/el/9 $rpm
done
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
needs: [package, version]
# for rpm in packages/*.rpm/*.rpm; do
# package_cloud push kentik/$REPO/el/7 $rpm
# package_cloud push kentik/$REPO/el/8 $rpm
# package_cloud push kentik/$REPO/el/9 $rpm
# done
# env:
# PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
# needs: [package, version]
45 changes: 45 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: publish

on:
workflow_dispatch:
push:
branches: publish-kentik-package

jobs:
package:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- armv7-unknown-linux-musleabihf
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# - name: generate bundle
# uses: ./.github/actions/bundle
# with:
# binary: kprobe-${{ matrix.target }}
# version: v2.5.0-rc1
# id: bundle
# - uses: actions/upload-artifact@v4
# with:
# name: ${{ steps.bundle.outputs.bundle }}
# path: ${{ steps.bundle.outputs.bundle }}


# publish:
# runs-on: ubuntu-latest
# continue-on-error: true
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# # - uses: actions/create-github-app-token@v1
# # id: token
# # with:
# # app-id: ${{ vars.KENTIK_MACHINERY_APP_ID }}
# # private-key: ${{ secrets.KENTIK_MACHINERY_PRIVATE_KEY }}
# # owner: ${{ github.repository_owner }}

0 comments on commit 9308144

Please sign in to comment.