name: Generate and Release Protos on: push: tags: - 'v*' jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 with: fetch-depth: 0 persist-credentials: false - name: Get Version id: get_version run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT - uses: actions/setup-go@v5 with: go-version: '1.24' - uses: actions/setup-node@v6 with: node-version: '18.18.x' registry-url: 'https://git.fjla.uk/api/packages/owlboard/npm' scope: '@owlboard' - name: Install Generators run: | npm install -g json-schema-to-typescript typescript go install github.com/atombender/go-jsonschema@latest echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - run: bash scripts/build.sh - name: Build and Publish TS working-directory: gen/ts run: | npm init -y # Build index.ts echo "// Auto-generated" > index.ts find . -maxdepth 1 -name "*.ts" -not -name "index.ts" | sed 's|^\./||; s|\.ts$||' | awk '{ # Use gsub to turn hyphens into underscores so we can split easily clean = $0; gsub(/-/, "_", clean); n = split(clean, parts, "_"); name = ""; for (i=1; i<=n; i++) { if (length(parts[i]) > 0) { name = name toupper(substr(parts[i],1,1)) substr(parts[i],2); } } # name will now be 'DataIngressPisData' (valid TS) printf "export * as %s from \"./%s.js\";\n", name, $0 }' >> index.ts VERSION="${{ steps.get_version.outputs.VERSION }}" REPO_URL="${{ github.server_url }}/${{ github.repository }}.git" jq --arg ver "$VERSION" \ --arg name "@owlboard/api-schema-types" \ --arg repo "$REPO_URL" \ '.name = $name | .description = "TypeScript type definitions for OwlBoard API schemas" | .author = "Frederick Boniface" | .version = $ver | .type = "module" | .main = "./dist/index.js" | .license = "MIT" | .repository = { "type": "git", "url": $repo } | .files = ["dist"] | .sideEffects = false | .dependencies = {} | .devDependencies = {} | .exports = { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } } | .types = "./dist/index.d.ts"' \ package.json > package.json.new && mv package.json.new package.json # Compile npx tsc index.ts --declaration --module nodenext --target es2022 --moduleResolution nodenext --outDir dist/ --skipLibCheck true # Publish npm config set //git.fjla.uk/api/packages/owlboard/npm/:_authToken ${{ secrets.PACKAGE_PUSH }} npm publish - name: Publish Go run: | VERSION="v${{ steps.get_version.outputs.VERSION }}" MOD_NAME="git.fjla.uk/owlboard/api-schema-types/v3" ZIP_ROOT="/tmp/go_upload" FULL_PATH="$ZIP_ROOT/$MOD_NAME@$VERSION" # 1. Prepare cd gen/go # 2. Initialize the module go mod init "$MOD_NAME" # 3. Create the structure mkdir -p "$FULL_PATH" # 4. Copy the CONTENTS of models to the root of the module # This flattens the structure so the .go files are next to go.mod cp -r models/* "$FULL_PATH/" cp go.mod "$FULL_PATH/" # 5. Zip and Upload cd "$ZIP_ROOT" zip -r -D "$GITHUB_WORKSPACE/module.zip" . curl -f --user "owlbot:${{ secrets.PACKAGE_PUSH }}" \ --upload-file "$GITHUB_WORKSPACE/module.zip" \ "${{ github.server_url }}/api/packages/owlboard/go/upload?version=$VERSION"