Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor GitHub workflows for better organization and clarity #386

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Compile TRACON Boundaries

name: Build Boundaries Only
on:
workflow_dispatch:
push:
tags:
- "v*"

jobs:
compile:
Expand All @@ -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
40 changes: 40 additions & 0 deletions .github/workflows/enforce_dir_structure.yml
Original file line number Diff line number Diff line change
@@ -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."
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: json-yaml-validate
name: Validate JSON and YAML files

on:
push:
branches:
Expand All @@ -18,6 +19,6 @@ jobs:

- name: json-yaml-validate
id: json-yaml-validate
uses: GrantBirki/[email protected] # replace with the latest version
uses: GrantBirki/[email protected]
with:
comment: "true" # enable comment mode
84 changes: 84 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
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/[email protected]
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
20 changes: 0 additions & 20 deletions .github/workflows/tagandrelease.yml

This file was deleted.

Loading