From 052b8bfb391775eeafafab769961aeb3a467e358 Mon Sep 17 00:00:00 2001 From: Tom <13634684+dirtyformal@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:23:31 +1200 Subject: [PATCH 1/3] Refactor GitHub workflows for better organization and clarity --- .../{build.yml => build_boundaries_only.yml} | 15 +--- .github/workflows/enforce_dir_structure.yml | 40 +++++++++ .../{json-validate.yaml => json_validate.yml} | 5 +- .github/workflows/release.yml | 82 +++++++++++++++++++ .github/workflows/tagandrelease.yml | 20 ----- 5 files changed, 126 insertions(+), 36 deletions(-) rename .github/workflows/{build.yml => build_boundaries_only.yml} (59%) create mode 100644 .github/workflows/enforce_dir_structure.yml rename .github/workflows/{json-validate.yaml => json_validate.yml} (78%) create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/tagandrelease.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build_boundaries_only.yml similarity index 59% rename from .github/workflows/build.yml rename to .github/workflows/build_boundaries_only.yml index 63470447..fe8316f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build_boundaries_only.yml @@ -1,10 +1,6 @@ -name: Compile TRACON Boundaries - +name: Build Boundaries Only on: workflow_dispatch: - push: - tags: - - "v*" jobs: compile: @@ -20,18 +16,9 @@ jobs: - name: Compile boundary files run: node compiler.js - - - name: Tag - run: echo ${{ github.sha }} > Release.txt - name: Upload artifact uses: actions/upload-artifact@v3 with: name: TRACONBoundaries path: TRACONBoundaries.geojson - - - name: Create release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: TRACONBoundaries.geojson diff --git a/.github/workflows/enforce_dir_structure.yml b/.github/workflows/enforce_dir_structure.yml new file mode 100644 index 00000000..5025d9f4 --- /dev/null +++ b/.github/workflows/enforce_dir_structure.yml @@ -0,0 +1,40 @@ +name: Enforce Directory Structure + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + enforce_dir_structure: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Validate Directory Structure + run: | + echo "Validating directory structure..." + for dir in Boundaries/*; do + if [ -d "$dir" ]; then + id=$(basename "$dir") + json_files=("$dir"/*.json) + if [ ${#json_files[@]} -eq 0 ]; then + echo "::error file=$dir::No JSON files found in directory $dir" + exit 1 + fi + for json_file in "${json_files[@]}"; do + if [[ ! "$json_file" =~ ^$dir/[^/]+\.json$ ]]; then + echo "::error file=$json_file::Invalid JSON file name or location: $json_file" + exit 1 + fi + done + else + echo "::error file=$dir::Invalid directory: $dir" + exit 1 + fi + done + echo "Directory structure is valid." diff --git a/.github/workflows/json-validate.yaml b/.github/workflows/json_validate.yml similarity index 78% rename from .github/workflows/json-validate.yaml rename to .github/workflows/json_validate.yml index 16b9e9df..0f28f269 100644 --- a/.github/workflows/json-validate.yaml +++ b/.github/workflows/json_validate.yml @@ -1,4 +1,5 @@ -name: json-yaml-validate +name: Validate JSON and YAML files + on: push: branches: @@ -18,6 +19,6 @@ jobs: - name: json-yaml-validate id: json-yaml-validate - uses: GrantBirki/json-yaml-validate@v2.4.0 # replace with the latest version + uses: GrantBirki/json-yaml-validate@v2.4.0 with: comment: "true" # enable comment mode diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f5df382c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,82 @@ +name: Version bump, build and release +on: + workflow_dispatch: +jobs: + compile: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Configure Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Compile Master Boundary File + run: node compiler.js + - name: Upload Master Boundary File + uses: actions/upload-artifact@v3 + with: + name: TRACONBoundaries + path: TRACONBoundaries.geojson + + create_release: + needs: compile + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v2 + - name: Download Master Boundary File + uses: actions/download-artifact@v2 + with: + name: TRACONBoundaries + path: . + + - name: Tag Version + id: tag_version + uses: mathieudutour/github-tag-action@v6.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + default_bump: patch + prefix: "v" + message: "Tag version to v${steps.tag_version.outputs.new_version}" + + - name: Fetch all tags + run: git fetch --tags + + - name: Generate Changelog + id: generate_changelog + run: | + PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") + NEW_TAG=${{ steps.tag_version.outputs.new_version }} + if [ -z "$PREVIOUS_TAG" ]; then + echo "No previous tag found. Generating changelog from the beginning of the repository." + CHANGELOG=$(git log --pretty=format:"* %s (%an)") + else + echo "Previous tag: $PREVIOUS_TAG" + echo "New tag: $NEW_TAG" + CHANGELOG=$(git log $PREVIOUS_TAG..HEAD --pretty=format:"* %s (%an)") + fi + echo "$CHANGELOG" > CHANGELOG.md + shell: bash + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ steps.tag_version.outputs.new_version }} + release_name: Release v${{ steps.tag_version.outputs.new_version }} + body_path: CHANGELOG.md + draft: false + prerelease: false + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./TRACONBoundaries.geojson + asset_name: TRACONBoundaries.geojson + asset_content_type: application/octet-stream diff --git a/.github/workflows/tagandrelease.yml b/.github/workflows/tagandrelease.yml deleted file mode 100644 index d3960c9c..00000000 --- a/.github/workflows/tagandrelease.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Bump version -on: - pull_request: - types: [closed] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Bump version and push tag - id: tag_version - uses: mathieudutour/github-tag-action@v6.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Create a GitHub release - uses: ncipollo/release-action@v1 - with: - tag: ${{ steps.tag_version.outputs.new_tag }} - name: Release ${{ steps.tag_version.outputs.new_tag }} - body: ${{ steps.tag_version.outputs.changelog }} From 30853bd6ac751e18c1a9b2a16e42e7f68e158825 Mon Sep 17 00:00:00 2001 From: Tom <13634684+dirtyformal@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:33:57 +1200 Subject: [PATCH 2/3] Refactor file structure for SUMU.json --- Boundaries/{ => SUMU}/SUMU.json | 342 ++++++++++++++++---------------- 1 file changed, 171 insertions(+), 171 deletions(-) rename Boundaries/{ => SUMU}/SUMU.json (95%) diff --git a/Boundaries/SUMU.json b/Boundaries/SUMU/SUMU.json similarity index 95% rename from Boundaries/SUMU.json rename to Boundaries/SUMU/SUMU.json index 8c6cc391..3e88993b 100644 --- a/Boundaries/SUMU.json +++ b/Boundaries/SUMU/SUMU.json @@ -1,171 +1,171 @@ -{ - "type": "Feature", - "properties": { - "id": "SUMU", - "prefix": [ - "SUMU" - ], - "name": "Carrasco Approach" - }, - "geometry": { - "type": "MultiPolygon", - "coordinates": [ - [ - [ - [ - -56.883888888889, - -34.982777777778 - ], - [ - -56.523931388889, - -34.544893611111 - ], - [ - -56.491604166667, - -34.510438888889 - ], - [ - -56.4557275, - -34.478432222222 - ], - [ - -56.416574444444, - -34.449114444444 - ], - [ - -56.374443333333, - -34.422705277778 - ], - [ - -56.329654444444, - -34.399403333333 - ], - [ - -56.282548888889, - -34.379383055556 - ], - [ - -56.233484722222, - -34.362794722222 - ], - [ - -56.182835833333, - -34.349761944444 - ], - [ - -56.1309875, - -34.340382777778 - ], - [ - -56.078334722222, - -34.334726944444 - ], - [ - -56.025277777778, - -34.332836944444 - ], - [ - -55.091666666667, - -34.358670277778 - ], - [ - -55.038593055556, - -34.360560277778 - ], - [ - -54.985923611111, - -34.366215833333 - ], - [ - -54.934059166667, - -34.375595277778 - ], - [ - -54.883394444444, - -34.388627777778 - ], - [ - -54.834315, - -34.405216111111 - ], - [ - -54.787194444444, - -34.425236388889 - ], - [ - -54.742391388889, - -34.448538333333 - ], - [ - -54.700246944444, - -34.474947222222 - ], - [ - -54.661081944444, - -34.504265 - ], - [ - -54.625193888889, - -34.536271388889 - ], - [ - -54.592856388889, - -34.570726111111 - ], - [ - -54.564315, - -34.607369444444 - ], - [ - -54.539787222222, - -34.645925555556 - ], - [ - -54.519459722222, - -34.686103055556 - ], - [ - -54.503486388889, - -34.727598888889 - ], - [ - -54.491989722222, - -34.770098611111 - ], - [ - -54.485056388889, - -34.813280277778 - ], - [ - -54.482739166667, - -34.856815833333 - ], - [ - -54.483333333333, - -34.866666666667 - ], - [ - -54.483333333333, - -36.166666666667 - ], - [ - -54.833333333333, - -36 - ], - [ - -55.000190277778, - -35.917798055556 - ], - [ - -56.717222222222, - -35.066111111111 - ], - [ - -56.883888888889, - -34.982777777778 - ] - ] - ] - ] - } -} +{ + "type": "Feature", + "properties": { + "id": "SUMU", + "prefix": [ + "SUMU" + ], + "name": "Carrasco Approach" + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ + -56.883888888889, + -34.982777777778 + ], + [ + -56.523931388889, + -34.544893611111 + ], + [ + -56.491604166667, + -34.510438888889 + ], + [ + -56.4557275, + -34.478432222222 + ], + [ + -56.416574444444, + -34.449114444444 + ], + [ + -56.374443333333, + -34.422705277778 + ], + [ + -56.329654444444, + -34.399403333333 + ], + [ + -56.282548888889, + -34.379383055556 + ], + [ + -56.233484722222, + -34.362794722222 + ], + [ + -56.182835833333, + -34.349761944444 + ], + [ + -56.1309875, + -34.340382777778 + ], + [ + -56.078334722222, + -34.334726944444 + ], + [ + -56.025277777778, + -34.332836944444 + ], + [ + -55.091666666667, + -34.358670277778 + ], + [ + -55.038593055556, + -34.360560277778 + ], + [ + -54.985923611111, + -34.366215833333 + ], + [ + -54.934059166667, + -34.375595277778 + ], + [ + -54.883394444444, + -34.388627777778 + ], + [ + -54.834315, + -34.405216111111 + ], + [ + -54.787194444444, + -34.425236388889 + ], + [ + -54.742391388889, + -34.448538333333 + ], + [ + -54.700246944444, + -34.474947222222 + ], + [ + -54.661081944444, + -34.504265 + ], + [ + -54.625193888889, + -34.536271388889 + ], + [ + -54.592856388889, + -34.570726111111 + ], + [ + -54.564315, + -34.607369444444 + ], + [ + -54.539787222222, + -34.645925555556 + ], + [ + -54.519459722222, + -34.686103055556 + ], + [ + -54.503486388889, + -34.727598888889 + ], + [ + -54.491989722222, + -34.770098611111 + ], + [ + -54.485056388889, + -34.813280277778 + ], + [ + -54.482739166667, + -34.856815833333 + ], + [ + -54.483333333333, + -34.866666666667 + ], + [ + -54.483333333333, + -36.166666666667 + ], + [ + -54.833333333333, + -36 + ], + [ + -55.000190277778, + -35.917798055556 + ], + [ + -56.717222222222, + -35.066111111111 + ], + [ + -56.883888888889, + -34.982777777778 + ] + ] + ] + ] + } +} From f88fca43b1ba5071a1dfc272bce56a80706269d2 Mon Sep 17 00:00:00 2001 From: Tom <13634684+dirtyformal@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:36:07 +1200 Subject: [PATCH 3/3] Fix formatting --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f5df382c..d2da81e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,8 +10,10 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 + - name: Compile Master Boundary File run: node compiler.js + - name: Upload Master Boundary File uses: actions/upload-artifact@v3 with: