Skip to content

Merge pull request #3 from streamfold/begin_packaging #27

Merge pull request #3 from streamfold/begin_packaging

Merge pull request #3 from streamfold/begin_packaging #27

Workflow file for this run

name: Continuous Deployment
on:
push:
tags:
- "v*.*.*"
env:
ROTEL_VERSION: "tags/v0.0.2"
jobs:
publish-npm-binaries:
name: Publish NPM packages
runs-on: ${{ matrix.build.os }}
strategy:
fail-fast: false
matrix:
build:
- {
NAME: linux-x64-glibc,
OS: ubuntu-20.04,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-gnu,
ARTIFACT: rotel_v0.0.2_x86_64-unknown-linux-gnu.tar.gz,
}
- {
NAME: linux-arm64-glibc,
OS: ubuntu-20.04,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-gnu,
ARTIFACT: rotel_v0.0.2_aarch64-unknown-linux-gnu.tar.gz,
}
- {
NAME: darwin-arm64,
OS: macos-14,
TOOLCHAIN: stable,
TARGET: aarch64-apple-darwin,
ARTIFACT: rotel_v0.0.2_aarch64-apple-darwin.tar.gz,
}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: update apt cache on linux
if: matrix.os == 'ubuntu'
run: sudo apt-get update
- name: Set build env
run: echo "BUILD_SHORT_SHA=$(echo -n $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
- name: Set the release version
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install node
uses: actions/setup-node@v3
with:
node-version: "16"
registry-url: "https://registry.npmjs.org"
- name: Download Rotel
uses: dsaltares/fetch-gh-release-asset@1.1.2
with:
repo: 'streamfold/rotel'
version: ${{ env.ROTEL_VERSION }}
file: ${{ matrix.build.ARTIFACT }}
token: ${{ secrets.AGENT_DOWNLOAD_TOKEN }}
- name: Publish to NPM
shell: bash
run: |
tar -O -zxf ${{matrix.build.ARTIFACT}} rotel > rotel-agent
rm ${{matrix.build.ARTIFACT}}
chmod +x rotel-agent
ls
cd npm
# set the binary name
bin="rotel-agent"
# derive the OS and architecture from the build matrix name
# note: when split by a hyphen, first part is the OS and the second is the architecture
node_os=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f1)
export node_os
node_arch=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f2)
export node_arch
# set the version
export node_version="${{ env.RELEASE_VERSION }}"
# set the package name
export node_pkg="${bin}-${node_os}-${node_arch}"
# create the package directory
mkdir -p "${node_pkg}/bin"
# generate package.json from the template
envsubst < package.json.tmpl > "${node_pkg}/package.json"
# copy the binary into the package
# note: windows binaries has '.exe' extension
cp ../rotel-agent "${node_pkg}/bin"
# publish the package
#cd "${node_pkg}"
#npm publish --access public --dry-run
- name: tar
run: |
tar -czf archive.tar.gz ./npm
- name: upload
run: |
id=$(gh api -H "Accept: application/vnd.github+json" /repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} --jq .id)
curl --fail-with-body -sS -X POST --data-binary @"archive.tar.gz" -H 'Content-Type: application/octet-stream' -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://uploads.github.com/repos/${{ github.repository }}/releases/$id/assets?name=rotel_${{ github.ref_name }}_${{ matrix.build.TARGET }}.tar.gz"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}