Some checks failed
Generate and Release Protos / release (push) Failing after 23s
92 lines
3.1 KiB
YAML
92 lines
3.1 KiB
YAML
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
|
|
|
|
# 1. Create the Namespaced index.ts from the FLAT files
|
|
# This turns 'rail_backend_v1_pis_mapping.ts' into 'RailBackendV1PisMapping'
|
|
find . -maxdepth 1 -name "*.ts" -not -name "index.ts" | sed 's|^\./||; s|\.ts$||' | awk '{
|
|
split($0, parts, "_");
|
|
namespace="";
|
|
for (i in parts) {
|
|
namespace = namespace toupper(substr(parts[i],1,1)) substr(parts[i],2);
|
|
}
|
|
printf "export * as %s from \"./%s.js\";\n", namespace, $0
|
|
}' > index.ts
|
|
|
|
# 2. Update package.json
|
|
VERSION="${{ steps.get_version.outputs.VERSION }}"
|
|
jq --arg ver "$VERSION" '.name = "@owlboard/backend-data-contracts" |
|
|
.version = $ver | .type = "module" | .main = "./dist/index.js" | .types = "./dist/index.d.ts"' \
|
|
package.json > temp.json && mv temp.json package.json
|
|
|
|
# 3. Compile (No tsconfig needed with these flags)
|
|
npx tsc index.ts --declaration --module nodenext --target es2022 --moduleResolution nodenext --outDir dist/ --skipLibCheck true
|
|
|
|
# 4. Publish
|
|
npm config set //git.fjla.uk/api/packages/owlboard/npm/:_authToken ${{ secrets.PACKAGE_PUSH }}
|
|
npm publish
|
|
|
|
- name: Publish Go
|
|
run: |
|
|
# 1. Setup variables
|
|
VERSION="${{ steps.get_version.outputs.VERSION }}"
|
|
MOD_NAME="git.fjla.uk/owlboard/backend-data-contracts"
|
|
# Create a temporary directory structure that matches Go proxy requirements
|
|
DEST_DIR="temp_zip/$MOD_NAME@$VERSION"
|
|
|
|
# 2. Generate go.mod and tidy
|
|
cd gen/go
|
|
go mod init $MOD_NAME
|
|
go mod tidy
|
|
|
|
# 3. Move files into the required nested structure
|
|
mkdir -p "../../$DEST_DIR"
|
|
cp -r . "../../$DEST_DIR/"
|
|
|
|
# 4. Zip from the temp root so the internal paths are correct
|
|
cd ../../temp_zip
|
|
zip -r ../module.zip .
|
|
|
|
# 5. Upload with the explicit version
|
|
cd ..
|
|
curl -f -v --user "owlbot:${{ secrets.PACKAGE_PUSH }}" \
|
|
--upload-file module.zip \
|
|
"${{ github.server_url }}/api/packages/owlboard/go/upload?version=$VERSION" |