From 590518f681fe2d24cb06df6b8c02a8398f4b4e1f Mon Sep 17 00:00:00 2001 From: Revyn112 Date: Wed, 11 Oct 2023 12:26:05 +0200 Subject: [PATCH] chore: update workflows fix --- ...-main.yml => a339x-livery-package-dev.yml} | 12 ++--- .../workflows/a339x-livery-package-exp.yml | 2 +- .../a339x-livery-package-release.yml | 2 +- .../a339x-livery-package-staging.yml | 2 +- .../workflows/{main.yml => development.yml} | 47 ++++--------------- .github/workflows/experimental.yml | 38 ++------------- .github/workflows/release.yml | 47 ++++--------------- .github/workflows/staging.yml | 40 +++------------- scripts/setup.sh | 11 ++++- 9 files changed, 49 insertions(+), 152 deletions(-) rename .github/workflows/{a339x-livery-package-main.yml => a339x-livery-package-dev.yml} (89%) rename .github/workflows/{main.yml => development.yml} (52%) diff --git a/.github/workflows/a339x-livery-package-main.yml b/.github/workflows/a339x-livery-package-dev.yml similarity index 89% rename from .github/workflows/a339x-livery-package-main.yml rename to .github/workflows/a339x-livery-package-dev.yml index ba4f43daf..edf614e1a 100644 --- a/.github/workflows/a339x-livery-package-main.yml +++ b/.github/workflows/a339x-livery-package-dev.yml @@ -1,10 +1,10 @@ -name: A339X Livery Package Main +name: A339X Livery Package Development on: push: branches: - main paths: - - '.github/workflows/a339x-livery-package-main.yml' + - '.github/workflows/a339x-livery-package-dev.yml' - 'hdw-a339x-liveries/**' - 'scripts/build-a339x-liveries.js' - 'scripts/build-a339x-liveries.sh' @@ -21,8 +21,8 @@ jobs: env: A32NX_PRODUCTION_BUILD: 1 A32NX_INSTRUMENTS_BUILD_WORKERS: 2 - ZIP_NAME: hdw-a339x-liveries-main.zip - BUILD_DIR_NAME: main + ZIP_NAME: hdw-a339x-liveries-dev.zip + BUILD_DIR_NAME: dev steps: - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main @@ -51,7 +51,7 @@ jobs: echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env - name: Setup Package run: | - ./scripts/dev-env/run.sh ./scripts/setup.sh + ./scripts/dev-env/run.sh ./scripts/setup.sh --clean - name: Copy Sources run: | ./scripts/dev-env/run.sh ./scripts/copy_a339x.sh @@ -70,6 +70,6 @@ jobs: - name: Upload to CloudFlare CDN env: CLOUDFLARE_WORKER_PASSWORD: ${{ secrets.CLOUDFLARE_WORKER_PASSWORD }} - CDN_BUCKET_DESTINATION: addons/a339x-livery-package/main + CDN_BUCKET_DESTINATION: addons/a339x-livery-package/dev run: | ./scripts/cdn.sh $CDN_BUCKET_DESTINATION ./hdw-a339x-liveries/out/build-modules \ No newline at end of file diff --git a/.github/workflows/a339x-livery-package-exp.yml b/.github/workflows/a339x-livery-package-exp.yml index 6afce7485..68ce62b26 100644 --- a/.github/workflows/a339x-livery-package-exp.yml +++ b/.github/workflows/a339x-livery-package-exp.yml @@ -51,7 +51,7 @@ jobs: echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env - name: Setup Package run: | - ./scripts/dev-env/run.sh ./scripts/setup.sh + ./scripts/dev-env/run.sh ./scripts/setup.sh --clean - name: Copy Sources run: | ./scripts/dev-env/run.sh ./scripts/copy_a339x.sh diff --git a/.github/workflows/a339x-livery-package-release.yml b/.github/workflows/a339x-livery-package-release.yml index 46a913b5d..fe01b76d1 100644 --- a/.github/workflows/a339x-livery-package-release.yml +++ b/.github/workflows/a339x-livery-package-release.yml @@ -54,7 +54,7 @@ jobs: echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env - name: Setup Package run: | - ./scripts/dev-env/run.sh ./scripts/setup.sh + ./scripts/dev-env/run.sh ./scripts/setup.sh --clean - name: Copy Sources run: | ./scripts/dev-env/run.sh ./scripts/copy_a339x.sh diff --git a/.github/workflows/a339x-livery-package-staging.yml b/.github/workflows/a339x-livery-package-staging.yml index 0b44e4656..ae2c385da 100644 --- a/.github/workflows/a339x-livery-package-staging.yml +++ b/.github/workflows/a339x-livery-package-staging.yml @@ -52,7 +52,7 @@ jobs: echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env - name: Setup Package run: | - ./scripts/dev-env/run.sh ./scripts/setup.sh + ./scripts/dev-env/run.sh ./scripts/setup.sh --clean - name: Copy Sources run: | ./scripts/dev-env/run.sh ./scripts/copy_a339x.sh diff --git a/.github/workflows/main.yml b/.github/workflows/development.yml similarity index 52% rename from .github/workflows/main.yml rename to .github/workflows/development.yml index 9569bd8b8..2f2264ac3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/development.yml @@ -1,4 +1,4 @@ -name: main +name: development on: push: branches: @@ -10,10 +10,8 @@ jobs: env: A32NX_PRODUCTION_BUILD: 1 A32NX_INSTRUMENTS_BUILD_WORKERS: 2 - PRE_RELEASE_ID: 64726828 - PRE_RELEASE_TAG: vmain - ZIP_NAME: headwindsim-aircraft-a330-900-main.zip - BUILD_DIR_NAME: main + ZIP_NAME: headwindsim-aircraft-a330-900-dev.zip + BUILD_DIR_NAME: development steps: - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main @@ -26,7 +24,7 @@ jobs: docker-images: false swap-storage: false - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive - name: Set BUILT_DATE_TIME @@ -42,7 +40,7 @@ jobs: echo VITE_BUILD=false >> .env - name: Setup Package run: | - ./scripts/dev-env/run.sh ./scripts/setup.sh + ./scripts/dev-env/run.sh ./scripts/setup.sh --clean - name: Copy Sources run: | ./scripts/dev-env/run.sh ./scripts/copy_a339x.sh @@ -58,35 +56,10 @@ jobs: cd ./build-a339x/out/ zip -r ../../${{ env.BUILD_DIR_NAME }}/${{ env.ZIP_NAME }} ./headwindsim-aircraft-a330-900/ cd ../../ - - name: Delete old GitHub Pre-Release assets - uses: mknejp/delete-release-assets@v1 - with: - token: ${{ github.token }} - tag: ${{ env.PRE_RELEASE_TAG }} - assets: "*" - fail-if-no-assets: false - - name: Upload aicraft package to GitHub Pre-Release Assets - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ env.PRE_RELEASE_ID }}/assets{?name,label} - asset_path: ./${{ env.BUILD_DIR_NAME }}/${{ env.ZIP_NAME }} - asset_name: ${{ env.ZIP_NAME }} - asset_content_type: application/zip - - name: Upload fragment assets to pre-release - uses: dwenegar/upload-release-assets@v1 + - name: Upload to CloudFlare CDN env: - GITHUB_TOKEN: ${{ github.token }} - with: - release_id: ${{ env.PRE_RELEASE_ID }} - assets_path: ./build-a339x/out/build-modules/ - - name: Update GitHub Pre-Release Body + CLOUDFLARE_WORKER_PASSWORD: ${{ secrets.CLOUDFLARE_WORKER_PASSWORD }} + CDN_BUCKET_DESTINATION: addons/a339x/development run: | - curl --request PATCH \ - --url 'https://api.github.com/repos/${{ github.repository }}/releases/${{ env.PRE_RELEASE_ID }}' \ - --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "body": "This pre-release has its asset updated on every commit to the main branch\nLast updated on ${{ env.BUILT_DATE_TIME }} from commit ${{ github.sha }}\n" - }' + ./scripts/cdn.sh $CDN_BUCKET_DESTINATION ./build-a339x/out/build-modules + \ No newline at end of file diff --git a/.github/workflows/experimental.yml b/.github/workflows/experimental.yml index 23e86c194..1b9354781 100644 --- a/.github/workflows/experimental.yml +++ b/.github/workflows/experimental.yml @@ -10,9 +10,7 @@ jobs: env: A32NX_PRODUCTION_BUILD: 1 A32NX_INSTRUMENTS_BUILD_WORKERS: 2 - EXP_PRE_RELEASE_ID: 79990124 - EXP_PRE_RELEASE_TAG: vexp - EXP_ZIP_NAME: headwindsim-aircraft-a330-900-experimental.zip + EXP_ZIP_NAME: headwindsim-aircraft-a330-900-exp.zip BUILD_DIR_NAME: experimental steps: - name: Free Disk Space (Ubuntu) @@ -58,35 +56,9 @@ jobs: cd ./build-a339x/out/ zip -r ../../${{ env.BUILD_DIR_NAME }}/${{ env.EXP_ZIP_NAME }} ./headwindsim-aircraft-a330-900/ cd ../../ - - name: Delete old release assets - uses: mknejp/delete-release-assets@v1 - with: - token: ${{ github.token }} - tag: ${{ env.EXP_PRE_RELEASE_TAG }} - assets: "*" - fail-if-no-assets: false - - name: Upload main zip asset to vexp release - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ env.EXP_PRE_RELEASE_ID }}/assets{?name,label} - asset_path: ./${{ env.BUILD_DIR_NAME }}/${{ env.EXP_ZIP_NAME }} - asset_name: ${{ env.EXP_ZIP_NAME }} - asset_content_type: application/zip - - name: Upload fragment assets to vexp release - uses: dwenegar/upload-release-assets@v1 + - name: Upload to CloudFlare CDN env: - GITHUB_TOKEN: ${{ github.token }} - with: - release_id: ${{ env.EXP_PRE_RELEASE_ID }} - assets_path: ./build-a339x/out/build-modules/ - - name: Update vexp release body + CLOUDFLARE_WORKER_PASSWORD: ${{ secrets.CLOUDFLARE_WORKER_PASSWORD }} + CDN_BUCKET_DESTINATION: addons/a339x-livery-package/exp run: | - curl --request PATCH \ - --url 'https://api.github.com/repos/${{ github.repository }}/releases/${{ env.EXP_PRE_RELEASE_ID }}' \ - --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "body": "This release has its asset updated on every commit to the experimental branch\nLast updated on ${{ env.BUILT_DATE_TIME }} from commit ${{ github.sha }}\n" - }' + ./scripts/cdn.sh $CDN_BUCKET_DESTINATION ./hdw-a339x-liveries/out/build-modules diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d951b30f8..040aceffd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,8 +13,6 @@ jobs: env: A32NX_PRODUCTION_BUILD: 1 A32NX_INSTRUMENTS_BUILD_WORKERS: 2 - PRE_RELEASE_ID: 64726773 - PRE_RELEASE_TAG: vstable ZIP_NAME: headwindsim-aircraft-a330-900-stable.zip BUILD_DIR_NAME: stable steps: @@ -29,7 +27,7 @@ jobs: docker-images: false swap-storage: false - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive - name: Create .env file @@ -43,7 +41,7 @@ jobs: echo VITE_BUILD=false >> .env - name: Setup Package run: | - ./scripts/dev-env/run.sh ./scripts/setup.sh + ./scripts/dev-env/run.sh ./scripts/setup.sh --clean - name: Copy Sources run: | ./scripts/dev-env/run.sh ./scripts/copy_a339x.sh @@ -59,6 +57,12 @@ jobs: cd ./build-a339x/out/ zip -r ../../${{ env.BUILD_DIR_NAME }}/${{ env.ZIP_NAME }} ./headwindsim-aircraft-a330-900/ cd ../../ + - name: Upload to CloudFlare CDN + env: + CLOUDFLARE_WORKER_PASSWORD: ${{ secrets.CLOUDFLARE_WORKER_PASSWORD }} + CDN_BUCKET_DESTINATION: addons/a339x/release + run: | + ./scripts/cdn.sh $CDN_BUCKET_DESTINATION ./build-a339x/out/build-modules - name: Create Release id: create_release uses: actions/create-release@v1 @@ -66,10 +70,10 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + release_name: ${{ github.ref }} draft: false prerelease: false - - name: Upload release asset + - name: Upload Release asset uses: actions/upload-release-asset@v1.0.2 env: GITHUB_TOKEN: ${{ github.token }} @@ -78,34 +82,3 @@ jobs: asset_path: ./${{ env.BUILD_DIR_NAME }}/${{ env.ZIP_NAME }} asset_name: ${{ env.ZIP_NAME }} asset_content_type: application/zip - - name: Delete old GitHub Pre-Release assets - uses: mknejp/delete-release-assets@v1 - with: - token: ${{ github.token }} - tag: ${{ env.PRE_RELEASE_TAG }} - assets: "*" - - name: Upload aicraft package to GitHub Pre-Release Assets - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ env.PRE_RELEASE_ID }}/assets{?name,label} - asset_path: ./${{ env.BUILD_DIR_NAME }}/${{ env.ZIP_NAME }} - asset_name: ${{ env.ZIP_NAME }} - asset_content_type: application/zip - - name: Upload fragment assets to pre-release - uses: dwenegar/upload-release-assets@v1 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - release_id: ${{ env.PRE_RELEASE_ID }} - assets_path: ./build-a339x/out/build-modules/ - - name: Update GitHub Pre-Release Body - run: | - curl --request PATCH \ - --url 'https://api.github.com/repos/${{ github.repository }}/releases/${{ env.PRE_RELEASE_ID }}' \ - --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "body": "This pre-release has its asset updated on every release\nLast updated on ${{ env.BUILT_DATE_TIME }} from commit ${{ github.sha }}\nThis link will always point to the latest stable build: https://github.com/${{ github.repository }}/releases/download/${{ env.PRE_RELEASE_TAG }}/${{ env.ZIP_NAME }}" - }' diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 77c471195..c31003cd8 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -12,8 +12,6 @@ jobs: A32NX_PRODUCTION_BUILD: 1 A32NX_INSTRUMENTS_BUILD_WORKERS: 2 ZIP_NAME: headwindsim-aircraft-a330-900-staging.zip - RELEASE_ID: 103223112 - RELEASE_TAG: vstaging BUILD_DIR_NAME: staging steps: - name: Free Disk Space (Ubuntu) @@ -27,7 +25,7 @@ jobs: docker-images: false swap-storage: false - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive - name: Set BUILT_DATE_TIME @@ -43,7 +41,7 @@ jobs: echo VITE_BUILD=false >> .env - name: Setup Package run: | - ./scripts/dev-env/run.sh ./scripts/setup.sh + ./scripts/dev-env/run.sh ./scripts/setup.sh --clean - name: Copy Sources run: | ./scripts/dev-env/run.sh ./scripts/copy_a339x.sh @@ -59,38 +57,12 @@ jobs: cd ./build-a339x/out/ zip -r ../../${{ env.BUILD_DIR_NAME }}/${{ env.ZIP_NAME }} ./headwindsim-aircraft-a330-900/ cd ../../ - - name: Delete old vstaging release assets - uses: mknejp/delete-release-assets@v1 - with: - token: ${{ github.token }} - tag: ${{ env.RELEASE_TAG }} - assets: "*" - fail-if-no-assets: false - - name: Upload zip asset to staging release - uses: actions/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }}/assets{?name,label} - asset_path: ./${{ env.BUILD_DIR_NAME }}/${{ env.ZIP_NAME }} - asset_name: ${{ env.ZIP_NAME }} - asset_content_type: application/zip - - name: Upload fragment assets to Release - uses: dwenegar/upload-release-assets@v1 + - name: Upload to CloudFlare CDN env: - GITHUB_TOKEN: ${{ github.token }} - with: - release_id: ${{ env.RELEASE_ID }} - assets_path: ./build-a339x/out/build-modules/ - - name: Update staging release body + CLOUDFLARE_WORKER_PASSWORD: ${{ secrets.CLOUDFLARE_WORKER_PASSWORD }} + CDN_BUCKET_DESTINATION: addons/a339x/staging run: | - curl --request PATCH \ - --url 'https://api.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }}' \ - --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "body": "This pre-release has its asset updated on every staging publish\nLast updated on ${{ env.BUILT_DATE_TIME }} from commit ${{ github.sha }}\nThis link will always point to the latest staging build: https://github.com/${{ github.repository }}/releases/download/${{ env.RELEASE_TAG }}/${{ env.ZIP_NAME }}" - }' + ./scripts/cdn.sh $CDN_BUCKET_DESTINATION ./build-a339x/out/build-modules - name: Create Release id: create_release uses: actions/create-release@v1 diff --git a/scripts/setup.sh b/scripts/setup.sh index f3f92e106..7d964ef2d 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -4,9 +4,16 @@ set -ex git config --global --add safe.directory "*" -# initialize submodule (a32nx) +# initialize submodule git submodule update --init --recursive cd /external -rm -rf node_modules + +for arg in "$@"; do + if [ "$arg" = "--clean" ]; then + echo "Removing node_modules..." + rm -rf node_modules/ + fi +done + npm ci \ No newline at end of file