Files
backend-data-contracts/.gitea/workflows/release.yaml
Fred Boniface 20cb7b101c
Some checks failed
Generate and Release Protos / release (push) Failing after 23s
Try fix workflow
2026-01-07 18:25:43 +00:00

102 lines
3.6 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: |
# 1. Initialize with defaults
npm init -y
# 2. Build index.ts carefully
# We ensure a space before 'from' and explicit double quotes around the path
echo "// Auto-generated" > index.ts
find . -maxdepth 1 -name "*.ts" -not -name "index.ts" | sed 's|^\./||; s|\.ts$||' | awk '{
# Create Namespace: split by underscore, capitalize each part
n = split($0, parts, "_");
name = "";
for (i=1; i<=n; i++) {
name = name toupper(substr(parts[i],1,1)) substr(parts[i],2);
}
# CRITICAL: Space before from, escaped quotes around path
printf "export * as %s from \"./%s.js\";\n", name, $0
}' >> index.ts
# 3. Debug: Print index.ts so we can see it in logs if it fails again
cat index.ts
# 4. Update package.json using a robust jq call
# We use --arg to ensure the VERSION string doesn't break the JSON
VERSION="${{ steps.get_version.outputs.VERSION }}"
jq --arg ver "$VERSION" \
--arg name "@owlboard/backend-data-contracts" \
'.name = $name | .version = $ver | .type = "module" | .main = "./dist/index.js" | .types = "./dist/index.d.ts"' \
package.json > package.json.tmp && mv package.json.tmp package.json
# 5. Compile with explicit flags
# We use 'nodenext' because it matches the .js extensions in our index.ts
npx tsc index.ts --declaration --module nodenext --target es2022 --moduleResolution nodenext --outDir dist/ --skipLibCheck true
# 6. Authenticate and 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"