Skip to content

Generate BCS schemas for emitted event structs (#2) #22

Generate BCS schemas for emitted event structs (#2)

Generate BCS schemas for emitted event structs (#2) #22

Workflow file for this run

name: Release
on:
push:
tags: ['v*']
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build:
permissions: {}
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
MOVE2TS_VERSION: ${{ github.ref_name }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
npm_pkg: linux-x64
archive: tar.gz
suffix: linux-x64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
npm_pkg: linux-arm64
archive: tar.gz
suffix: linux-arm64
- target: aarch64-apple-darwin
os: macos-latest
npm_pkg: darwin-arm64
archive: zip
suffix: macos-arm64
- target: x86_64-pc-windows-msvc
os: windows-latest
npm_pkg: win32-x64
archive: zip
suffix: windows-x64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install aarch64 cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Configure aarch64 linker
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
mkdir -p .cargo
cat > .cargo/config.toml <<'EOF'
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
EOF
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package (tar.gz)
if: matrix.archive == 'tar.gz'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../move2ts-${{ matrix.suffix }}.tar.gz move2ts
shell: bash
- name: Package (zip, Unix)
if: matrix.archive == 'zip' && runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
zip ../../../move2ts-${{ matrix.suffix }}.zip move2ts
- name: Package (zip, Windows)
if: matrix.archive == 'zip' && runner.os == 'Windows'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../move2ts-${{ matrix.suffix }}.zip move2ts.exe
shell: bash
- uses: actions/upload-artifact@v4
with:
name: move2ts-${{ matrix.suffix }}
path: move2ts-${{ matrix.suffix }}.${{ matrix.archive }}
release:
needs: build
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Generate checksums
run: sha256sum move2ts-*.* > checksums-sha256.txt
- uses: softprops/action-gh-release@v2
with:
files: |
move2ts-*.*
checksums-sha256.txt
generate_release_notes: true
update-homebrew:
needs: release
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download checksums from release
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
VERSION="${GITHUB_REF_NAME#v}"
gh release download "$GITHUB_REF_NAME" \
--repo avbel/move2ts \
--pattern checksums-sha256.txt
MACOS_ARM64=$(grep 'move2ts-macos-arm64.zip' checksums-sha256.txt | awk '{print $1}')
LINUX_X64=$(grep 'move2ts-linux-x64.tar.gz' checksums-sha256.txt | awk '{print $1}')
LINUX_ARM64=$(grep 'move2ts-linux-arm64.tar.gz' checksums-sha256.txt | awk '{print $1}')
git clone "https://x-access-token:${GH_TOKEN}@github.com/avbel/homebrew-tap.git" /tmp/homebrew-tap
sed -i "s/version \".*\"/version \"$VERSION\"/" /tmp/homebrew-tap/Formula/move2ts.rb
# Update sha256 for macos arm64 (first sha256 in file)
awk -v new="$MACOS_ARM64" '
/sha256/ { count++ }
count == 1 && /sha256/ { sub(/"[a-f0-9]{64}"/, "\"" new "\""); count = -999 }
{ print }
' /tmp/homebrew-tap/Formula/move2ts.rb > /tmp/formula.tmp && mv /tmp/formula.tmp /tmp/homebrew-tap/Formula/move2ts.rb
# Update sha256 for linux x64 (second sha256)
awk -v new="$LINUX_X64" '
/sha256/ { count++ }
count == 2 && /sha256/ { sub(/"[a-f0-9]{64}"/, "\"" new "\""); count = -999 }
{ print }
' /tmp/homebrew-tap/Formula/move2ts.rb > /tmp/formula.tmp && mv /tmp/formula.tmp /tmp/homebrew-tap/Formula/move2ts.rb
# Update sha256 for linux arm64 (third sha256)
awk -v new="$LINUX_ARM64" '
/sha256/ { count++ }
count == 3 && /sha256/ { sub(/"[a-f0-9]{64}"/, "\"" new "\""); count = -999 }
{ print }
' /tmp/homebrew-tap/Formula/move2ts.rb > /tmp/formula.tmp && mv /tmp/formula.tmp /tmp/homebrew-tap/Formula/move2ts.rb
cd /tmp/homebrew-tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/move2ts.rb
git commit -m "Update move2ts to $VERSION"
git push
publish-npm:
needs: build
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- name: Stamp version from git tag
env:
TAG_NAME: ${{ github.ref_name }}
run: |
VERSION="${TAG_NAME#v}"
for pkg in npm/*/package.json; do
jq --arg v "$VERSION" '
.version = $v |
if .optionalDependencies then
.optionalDependencies |= with_entries(.value = $v)
else . end
' "$pkg" > tmp && mv tmp "$pkg"
done
- name: Extract and assemble platform binaries
run: |
tar xzf move2ts-linux-x64.tar.gz -C npm/linux-x64/
tar xzf move2ts-linux-arm64.tar.gz -C npm/linux-arm64/
unzip -o move2ts-macos-arm64.zip -d npm/darwin-arm64/
unzip -o move2ts-windows-x64.zip -d npm/win32-x64/
chmod +x npm/linux-x64/move2ts npm/linux-arm64/move2ts npm/darwin-arm64/move2ts
- name: Publish platform packages then main package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
ROOT="$PWD"
for pkg in linux-x64 linux-arm64 darwin-arm64 win32-x64; do
cd "$ROOT/npm/$pkg" && pnpm publish --access public --no-git-checks --provenance
done
cd "$ROOT/npm/move2ts" && pnpm publish --access public --no-git-checks --provenance