Add update-spec.yml workflow #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
pull_request: | |
branches: [master] | |
paths: | |
- .github/workflows/update-spec.yml | |
workflow_dispatch: | |
inputs: | |
repository: | |
description: Spec repository from which to generate code | |
type: string | |
default: oneapi-src/level-zero-spec | |
ref: | |
description: Ref to checkout from the spec repository | |
type: string | |
default: master | |
version: | |
description: Version of the spec to generate code for | |
type: string | |
branch: | |
description: Branch to (force) push generated code to | |
type: string | |
default: spec-develop | |
concurrency: spec-develop | |
jobs: | |
update-headers: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: pip install Mako==1.1.0 PyYAML==5.2 | |
- uses: actions/checkout@v3 | |
with: | |
clean: true | |
fetch-depth: 0 | |
fetch-tags: true | |
token: ${{ secrets.TOKEN }} | |
- name: Checkout develop branch or create local version | |
run: git checkout ${{ inputs.branch }} || git checkout -b ${{ inputs.branch }} | |
- name: Reset develop branch to master | |
run: git reset --hard origin/master | |
- name: Checkout spec repository | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ inputs.repository }} | |
clean: true | |
fetch-depth: 0 | |
path: spec | |
ref: ${{ inputs.ref }} | |
- name: Apply latest spec commit to develop branch | |
run: | #bash | |
export LANG="C.UTF-8" | |
pushd spec/scripts | |
python3 ./run.py --debug '--!html' '--!rst' '--!build' --ver ${{ inputs.version }} | |
popd | |
./scripts/json2src.py < spec/scripts/input.json --ver ${{ inputs.version }} . | |
if (($(git diff | tee >(wc -l) >&2) == 0)); then | |
echo "::warning::No changes were made to files" | |
else | |
git config user.email "sys-lzdev@intel.com" | |
git config user.name "sys-lzdev" | |
spec_ver=$(sed -n 's/^.*version v.*-r\([0-9]*\.[0-9]*\.[0-9]*\)/\1/p' include/ze_api.h) | |
git add -u | |
git commit -m "Update to spec ${spec_ver}" | |
fi | |
- name: Push changes to develop branch | |
if: ${{ github.event_name != 'pull_request' }} | |
run: git push origin ${{ inputs.branch }} -f |