From 0215b8e7634b4f8bd507abf9c3cc0872e2610ffe Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 08:03:05 +0000 Subject: [PATCH 01/12] includes architecture in alfa command name --- .gitignore | 4 ++-- install.sh | 16 +++++++++------- rename.sh | 16 +++++++++------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 5ba7b1d..716c357 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,5 @@ pubspec.lock # alfa executables /alfa -/alfa_linux -/alfa_macos +/alfa_linux* +/alfa_macos* diff --git a/install.sh b/install.sh index 744800c..075363b 100755 --- a/install.sh +++ b/install.sh @@ -10,14 +10,16 @@ fi alfaCommand="" -# sets the alfa command variable based on the operating system -unameResults="$(uname -s)" -if [[ "Linux" == *"$unameResults"* ]]; then - alfaCommand="alfa_linux" -elif [[ "Darwin" == *"$unameResults"* ]]; then - alfaCommand="alfa_macos" +# renames the alfa executable based on the operating system and architecture +unameSystem="$(uname -s)" +unameMachine="$(uname -m)" + +if [[ "Linux" == "$unameSystem" && ( "x86_64" == "$unameMachine" || "aarch64" == "$unameMachine" ) ]]; then + alfaCommand="alfa_linux_$unameMachine" +elif [[ "Darwin" == "$unameSystem" && ( "x86_64" == "$unameMachine" || "arm64" == "$unameMachine" ) ]]; then + alfaCommand="alfa_macos_$unameMachine" else - echo "alfa cannot run on ${unameResults}. It can only run on Linux and macOS." + echo "alfa cannot run on ${unameSystem} ${unameMachine}. It can only run on Linux and macOS." exit 1 fi diff --git a/rename.sh b/rename.sh index cae09cc..384ce14 100755 --- a/rename.sh +++ b/rename.sh @@ -8,14 +8,16 @@ if [[ ! -f "alfa" ]]; then exit 1 fi -# renames the alfa executable based on the operating system -unameResults="$(uname -s)" -if [[ "Linux" == *"$unameResults"* ]]; then - alfaCommand="alfa_linux" -elif [[ "Darwin" == *"$unameResults"* ]]; then - alfaCommand="alfa_macos" +# renames the alfa executable based on the operating system and architecture +unameSystem="$(uname -s)" +unameMachine="$(uname -m)" + +if [[ "Linux" == "$unameSystem" && ( "x86_64" == "$unameMachine" || "aarch64" == "$unameMachine" ) ]]; then + alfaCommand="alfa_linux_$unameMachine" +elif [[ "Darwin" == "$unameSystem" && ( "x86_64" == "$unameMachine" || "arm64" == "$unameMachine" ) ]]; then + alfaCommand="alfa_macos_$unameMachine" else - echo "alfa cannot run on ${unameResults}. It can only run on Linux and macOS." + echo "alfa cannot run on ${unameSystem} ${unameMachine}. It can only run on Linux and macOS." exit 1 fi From 19838d924122d900697c97df9b548995c6b7095a Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 08:17:09 +0000 Subject: [PATCH 02/12] testing --- .github/workflows/build_alfa_cli.yml | 125 +++++++++++++++++++-------- 1 file changed, 89 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build_alfa_cli.yml b/.github/workflows/build_alfa_cli.yml index 650d8dd..a0c730d 100644 --- a/.github/workflows/build_alfa_cli.yml +++ b/.github/workflows/build_alfa_cli.yml @@ -9,53 +9,106 @@ on: workflow_dispatch: jobs: - tag: - runs-on: ubuntu-latest + # tag: + # runs-on: ubuntu-latest + # timeout-minutes: 15 - outputs: - tag: ${{ steps.create-tag.outputs.tag }} + # outputs: + # tag: ${{ steps.create-tag.outputs.tag }} - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: '0' - - name: Bump version and create tag - id: create-tag - uses: anothrNick/github-tag-action@1.40.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WITH_V: true + # steps: + # - uses: actions/checkout@v2 + # with: + # fetch-depth: '0' + # - name: Bump version and create tag + # id: create-tag + # uses: anothrNick/github-tag-action@1.40.0 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # WITH_V: true + + # release: + # needs: tag + # runs-on: ${{ matrix.os }} + # timeout-minutes: 15 + + # strategy: + # matrix: + # os: [ ubuntu-latest, macos-latest ] + + # steps: + # - uses: actions/checkout@v2 + # with: + # fetch-depth: '0' + + # - uses: dart-lang/setup-dart@v1.3 + # with: + # sdk: stable + + # - name: Install dependencies + # run: dart pub get - release: - needs: tag - runs-on: ${{ matrix.os }} + # - name: Compile Executable + # id: compile + # run: | + # make - strategy: - matrix: - os: [ ubuntu-latest, macos-latest ] + # ./rename.sh + + # - name: Upload binary to release + # uses: svenstaro/upload-release-action@v2 + # with: + # file: alfa_* + # tag: ${{ needs.tag.outputs.tag }} + # file_glob: true + + release-on-arm: + # needs: tag + runs-on: ubuntu-latest + timeout-minutes: 15 steps: - uses: actions/checkout@v2 with: fetch-depth: '0' - - - uses: dart-lang/setup-dart@v1.3 + - uses: uraimo/run-on-arch-action@v2 + name: Create file with: - sdk: stable + arch: aarch64 + distro: ubuntu_latest - - name: Install dependencies - run: dart pub get + install: | + apt-get update && \ + apt-get install -y --no-install-recommends gnupg2 curl git ca-certificates apt-transport-https openssh-client && \ + curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ + curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \ + apt-get update && \ + apt-get install -y --no-install-recommends dart && \ + dart --disable-analytics && \ + apt-get clean -y && \ + rm -rf \ + /var/cache/debconf/* \ + /var/lib/apt/lists/* \ + /tmp/* \ + /var/tmp/* - - name: Compile Executable - id: compile - run: | - make + run: | + # installs dependencies + dart pub get - ./rename.sh + # builds executable + make - - name: Upload binary to release - uses: svenstaro/upload-release-action@v2 - with: - file: alfa_* - tag: ${{ needs.tag.outputs.tag }} - file_glob: true + # renames executable + ./rename.sh + + - name: Testing + run: | + ls -alth + + # - name: Upload binaries to release + # uses: svenstaro/upload-release-action@v2 + # with: + # file: alfa_* + # tag: ${{ needs.tag.outputs.tag }} + # file_glob: true From c89e9be5bf896d485e547b29176f2e9190a7b261 Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 08:54:24 +0000 Subject: [PATCH 03/12] testing --- .github/workflows/build_alfa_cli.yml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build_alfa_cli.yml b/.github/workflows/build_alfa_cli.yml index a0c730d..24500a1 100644 --- a/.github/workflows/build_alfa_cli.yml +++ b/.github/workflows/build_alfa_cli.yml @@ -78,19 +78,21 @@ jobs: distro: ubuntu_latest install: | - apt-get update && \ - apt-get install -y --no-install-recommends gnupg2 curl git ca-certificates apt-transport-https openssh-client && \ - curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \ - apt-get update && \ - apt-get install -y --no-install-recommends dart && \ - dart --disable-analytics && \ - apt-get clean -y && \ - rm -rf \ - /var/cache/debconf/* \ - /var/lib/apt/lists/* \ - /tmp/* \ - /var/tmp/* + apt-get update + apt-get install -y --no-install-recommends gnupg2 curl git ca-certificates apt-transport-https openssh-client + curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - + curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list + apt-get update + apt-get install -y --no-install-recommends dart + dart --disable-analytics + apt-get clean -y + rm -rf \ + /var/cache/debconf/* \ + /var/lib/apt/lists/* \ + /tmp/* \ + /var/tmp/* + + export PATH="$PATH:/usr/lib/dart/bin" run: | # installs dependencies From 3216b3edde258ad207ac70b08ae28f855b0b4072 Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 09:09:29 +0000 Subject: [PATCH 04/12] installs dart from zip file --- .github/workflows/build_alfa_cli.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_alfa_cli.yml b/.github/workflows/build_alfa_cli.yml index 24500a1..b10aec9 100644 --- a/.github/workflows/build_alfa_cli.yml +++ b/.github/workflows/build_alfa_cli.yml @@ -79,20 +79,16 @@ jobs: install: | apt-get update - apt-get install -y --no-install-recommends gnupg2 curl git ca-certificates apt-transport-https openssh-client - curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - - curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list - apt-get update - apt-get install -y --no-install-recommends dart - dart --disable-analytics - apt-get clean -y - rm -rf \ - /var/cache/debconf/* \ - /var/lib/apt/lists/* \ - /tmp/* \ - /var/tmp/* - - export PATH="$PATH:/usr/lib/dart/bin" + apt-get install -y --no-install-recommends ca-certificates curl dnsutils git openssh-client unzip + + SDK="dartsdk-linux-arm64-release.zip" + DART_SDK="/usr/lib/dart" + + curl -fLO "https://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/$SDK" + unzip "$SDK" && mv dart-sdk "$DART_SDK" && rm "$SDK" \ + && chmod 755 "$DART_SDK" && chmod 755 "$DART_SDK/bin" + + export PATH="$DART_SDK/bin:$PATH" run: | # installs dependencies From 41516679bdfb671798e35fb4b4f25cdc436200fd Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 10:07:47 +0000 Subject: [PATCH 05/12] testing --- .github/workflows/build_alfa_cli.yml | 67 +++++++++++++++++++--------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build_alfa_cli.yml b/.github/workflows/build_alfa_cli.yml index b10aec9..dfe4490 100644 --- a/.github/workflows/build_alfa_cli.yml +++ b/.github/workflows/build_alfa_cli.yml @@ -71,34 +71,59 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: '0' - - uses: uraimo/run-on-arch-action@v2 - name: Create file - with: - arch: aarch64 - distro: ubuntu_latest + - name: Setup non-x86 emulation with qemu + run: | + sudo apt-get update -q -y + sudo apt-get -qq install -y qemu qemu-user-static + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes + + - name: Build arm executable with docker + run: | + docker run \ + --rm \ + -t \ + -v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \ + --platform linux/arm64 \ + dart/stable \ + uname -a + + # - uses: uraimo/run-on-arch-action@v2 + # name: Build Arm Executable + # with: + # arch: aarch64 + # distro: ubuntu_latest + + # install: | + # # installs dependencies + # apt-get update + # apt-get install -y --no-install-recommends ca-certificates curl dnsutils git openssh-client unzip - install: | - apt-get update - apt-get install -y --no-install-recommends ca-certificates curl dnsutils git openssh-client unzip + # # install latest stable dart version for arm64 + # SDK="dartsdk-linux-arm64-release.zip" + # DART_SDK="/usr/lib/dart" - SDK="dartsdk-linux-arm64-release.zip" - DART_SDK="/usr/lib/dart" + # curl -fLO "https://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/$SDK" + # unzip "$SDK" && mv dart-sdk "$DART_SDK" && rm "$SDK" \ + # && chmod 755 "$DART_SDK" && chmod 755 "$DART_SDK/bin" - curl -fLO "https://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/$SDK" - unzip "$SDK" && mv dart-sdk "$DART_SDK" && rm "$SDK" \ - && chmod 755 "$DART_SDK" && chmod 755 "$DART_SDK/bin" + # export PATH="$DART_SDK/bin:$PATH" - export PATH="$DART_SDK/bin:$PATH" + # # cleans up + # rm -rf \ + # /var/cache/debconf/* \ + # /var/lib/apt/lists/* \ + # /tmp/* \ + # /var/tmp/* - run: | - # installs dependencies - dart pub get + # run: | + # # installs dependencies + # dart pub get - # builds executable - make + # # builds executable + # make - # renames executable - ./rename.sh + # # renames executable + # ./rename.sh - name: Testing run: | From fdae1c1ae0f8ab3f34025b57af40ee37506ec1ad Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 10:10:04 +0000 Subject: [PATCH 06/12] spelling --- .github/workflows/build_alfa_cli.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_alfa_cli.yml b/.github/workflows/build_alfa_cli.yml index dfe4490..0174620 100644 --- a/.github/workflows/build_alfa_cli.yml +++ b/.github/workflows/build_alfa_cli.yml @@ -84,7 +84,7 @@ jobs: -t \ -v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \ --platform linux/arm64 \ - dart/stable \ + dart:stable \ uname -a # - uses: uraimo/run-on-arch-action@v2 From 2c960199cd26933624bfb6cae9818744a7e17876 Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 10:29:07 +0000 Subject: [PATCH 07/12] tries to build multiline script --- .github/workflows/build_alfa_cli.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_alfa_cli.yml b/.github/workflows/build_alfa_cli.yml index 0174620..8a1b4b7 100644 --- a/.github/workflows/build_alfa_cli.yml +++ b/.github/workflows/build_alfa_cli.yml @@ -77,6 +77,30 @@ jobs: sudo apt-get -qq install -y qemu qemu-user-static docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes + - name: Create entrypoint script + run: | + SCRIPT=$(cat << EOF + #!/bin/sh + set -eu + + # installs dependencies + dart pub get + + # builds executable + make + + # renames executable + ./rename.sh + EOF + ) + + echo "$SCRIPT" > run.sh + + chmod +x run.sh + + - name: cat file + run: cat run.sh + - name: Build arm executable with docker run: | docker run \ @@ -85,7 +109,7 @@ jobs: -v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \ --platform linux/arm64 \ dart:stable \ - uname -a + run.sh # - uses: uraimo/run-on-arch-action@v2 # name: Build Arm Executable From 117de026def7941af8c2edb77e59bfea40791184 Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 10:32:47 +0000 Subject: [PATCH 08/12] fixes script path and cleanup --- .github/workflows/build_alfa_cli.yml | 46 +++------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build_alfa_cli.yml b/.github/workflows/build_alfa_cli.yml index 8a1b4b7..374db64 100644 --- a/.github/workflows/build_alfa_cli.yml +++ b/.github/workflows/build_alfa_cli.yml @@ -71,13 +71,13 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: '0' - - name: Setup non-x86 emulation with qemu + - name: Setup arm emulation with qemu run: | sudo apt-get update -q -y sudo apt-get -qq install -y qemu qemu-user-static docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes - - name: Create entrypoint script + - name: Create docker command script run: | SCRIPT=$(cat << EOF #!/bin/sh @@ -98,7 +98,7 @@ jobs: chmod +x run.sh - - name: cat file + - name: Cat docker command script run: cat run.sh - name: Build arm executable with docker @@ -109,45 +109,7 @@ jobs: -v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \ --platform linux/arm64 \ dart:stable \ - run.sh - - # - uses: uraimo/run-on-arch-action@v2 - # name: Build Arm Executable - # with: - # arch: aarch64 - # distro: ubuntu_latest - - # install: | - # # installs dependencies - # apt-get update - # apt-get install -y --no-install-recommends ca-certificates curl dnsutils git openssh-client unzip - - # # install latest stable dart version for arm64 - # SDK="dartsdk-linux-arm64-release.zip" - # DART_SDK="/usr/lib/dart" - - # curl -fLO "https://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/$SDK" - # unzip "$SDK" && mv dart-sdk "$DART_SDK" && rm "$SDK" \ - # && chmod 755 "$DART_SDK" && chmod 755 "$DART_SDK/bin" - - # export PATH="$DART_SDK/bin:$PATH" - - # # cleans up - # rm -rf \ - # /var/cache/debconf/* \ - # /var/lib/apt/lists/* \ - # /tmp/* \ - # /var/tmp/* - - # run: | - # # installs dependencies - # dart pub get - - # # builds executable - # make - - # # renames executable - # ./rename.sh + "${GITHUB_WORKSPACE}/run.sh" - name: Testing run: | From 53f3b81fc9c56d8d00980293aa1b1851a884e441 Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 10:35:34 +0000 Subject: [PATCH 09/12] sets working directory --- .github/workflows/build_alfa_cli.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_alfa_cli.yml b/.github/workflows/build_alfa_cli.yml index 374db64..1bccf32 100644 --- a/.github/workflows/build_alfa_cli.yml +++ b/.github/workflows/build_alfa_cli.yml @@ -106,6 +106,7 @@ jobs: docker run \ --rm \ -t \ + --workdir "${GITHUB_WORKSPACE}" \ -v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \ --platform linux/arm64 \ dart:stable \ From 9be00dadd633020e39da6c3cfe987b84fc6294d1 Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 10:42:11 +0000 Subject: [PATCH 10/12] doesn't use make --- .github/workflows/build_alfa_cli.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_alfa_cli.yml b/.github/workflows/build_alfa_cli.yml index 1bccf32..67195b1 100644 --- a/.github/workflows/build_alfa_cli.yml +++ b/.github/workflows/build_alfa_cli.yml @@ -86,8 +86,8 @@ jobs: # installs dependencies dart pub get - # builds executable - make + # builds executable (make isn't part of this docker image) + dart compile exe bin/alfa.dart -o alfa # renames executable ./rename.sh From 34338a3615a3ac5d6de72ef3235feb9b42fa75fe Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 11:04:05 +0000 Subject: [PATCH 11/12] undoes testing and adds codemagic config --- .github/workflows/build_alfa_cli.yml | 124 +++++++++++++-------------- codemagic.yaml | 36 ++++++++ 2 files changed, 96 insertions(+), 64 deletions(-) create mode 100644 codemagic.yaml diff --git a/.github/workflows/build_alfa_cli.yml b/.github/workflows/build_alfa_cli.yml index 67195b1..9ce7594 100644 --- a/.github/workflows/build_alfa_cli.yml +++ b/.github/workflows/build_alfa_cli.yml @@ -9,61 +9,61 @@ on: workflow_dispatch: jobs: - # tag: - # runs-on: ubuntu-latest - # timeout-minutes: 15 - - # outputs: - # tag: ${{ steps.create-tag.outputs.tag }} - - # steps: - # - uses: actions/checkout@v2 - # with: - # fetch-depth: '0' - # - name: Bump version and create tag - # id: create-tag - # uses: anothrNick/github-tag-action@1.40.0 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # WITH_V: true - - # release: - # needs: tag - # runs-on: ${{ matrix.os }} - # timeout-minutes: 15 - - # strategy: - # matrix: - # os: [ ubuntu-latest, macos-latest ] - - # steps: - # - uses: actions/checkout@v2 - # with: - # fetch-depth: '0' - - # - uses: dart-lang/setup-dart@v1.3 - # with: - # sdk: stable - - # - name: Install dependencies - # run: dart pub get - - # - name: Compile Executable - # id: compile - # run: | - # make - - # ./rename.sh - - # - name: Upload binary to release - # uses: svenstaro/upload-release-action@v2 - # with: - # file: alfa_* - # tag: ${{ needs.tag.outputs.tag }} - # file_glob: true + tag: + runs-on: ubuntu-latest + timeout-minutes: 15 + + outputs: + tag: ${{ steps.create-tag.outputs.tag }} + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + - name: Bump version and create tag + id: create-tag + uses: anothrNick/github-tag-action@1.40.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WITH_V: true + + release: + needs: tag + runs-on: ${{ matrix.os }} + timeout-minutes: 15 + + strategy: + matrix: + os: [ ubuntu-latest, macos-latest ] + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + + - uses: dart-lang/setup-dart@v1.3 + with: + sdk: stable + + - name: Install dependencies + run: dart pub get + + - name: Compile Executable + id: compile + run: | + make + + ./rename.sh + + - name: Upload binary to release + uses: svenstaro/upload-release-action@v2 + with: + file: alfa_* + tag: ${{ needs.tag.outputs.tag }} + file_glob: true release-on-arm: - # needs: tag + needs: tag runs-on: ubuntu-latest timeout-minutes: 15 @@ -86,7 +86,7 @@ jobs: # installs dependencies dart pub get - # builds executable (make isn't part of this docker image) + # compile executable (make isn't part of this docker image) dart compile exe bin/alfa.dart -o alfa # renames executable @@ -112,13 +112,9 @@ jobs: dart:stable \ "${GITHUB_WORKSPACE}/run.sh" - - name: Testing - run: | - ls -alth - - # - name: Upload binaries to release - # uses: svenstaro/upload-release-action@v2 - # with: - # file: alfa_* - # tag: ${{ needs.tag.outputs.tag }} - # file_glob: true + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + file: alfa_* + tag: ${{ needs.tag.outputs.tag }} + file_glob: true diff --git a/codemagic.yaml b/codemagic.yaml new file mode 100644 index 0000000..ed19081 --- /dev/null +++ b/codemagic.yaml @@ -0,0 +1,36 @@ +workflows: + release: + name: Release + instance_type: mac_mini_m1 + max_build_duration: 15 + environment: + flutter: stable + + groups: + - github + + triggering: + events: + - tag + tag_patterns: + - pattern: 'v*' + + scripts: + - name: Add Dart SDK to PATH + script: | + echo PATH="$PATH":"$FLUTTER_ROOT/.pub-cache/bin" >> $CM_ENV + echo PATH="$PATH":"$FLUTTER_ROOT/bin" >> $CM_ENV + - name: Install dependencies + script: dart pub get + - name: Compile executable + script: make + - name: Renames executable + script: ./rename.sh + + artifacts: + - alfa_macos_arm64 + + publishing: + scripts: + - name: Publish to GitHub + script: gh release upload "${CM_TAG}" alfa_macos_arm64 From 696a0e84d122eeb3c9146e6f6d353b3f7b72cd53 Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Sat, 17 Sep 2022 11:31:59 +0000 Subject: [PATCH 12/12] passes the system architecture as an environment variable to the installer functions --- bin/alfa.dart | 5 +++-- functions.sh | 5 +++-- install.sh | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/alfa.dart b/bin/alfa.dart index 5e42400..d6b2b2f 100644 --- a/bin/alfa.dart +++ b/bin/alfa.dart @@ -58,6 +58,7 @@ void main(List args) async { // gets environment variables String user = Platform.environment['SUDO_USER']; String alfaUser = Platform.environment['ALFA_USER']; + String alfaArch = Platform.environment['ALFA_ARCH']; if (user == 'root' && alfaUser != '') { user = alfaUser; } @@ -65,7 +66,7 @@ void main(List args) async { // gets operating system // valid options (linux, macos) var osName = Platform.operatingSystem; - print("Running alfa on ${osName}"); + print("Running alfa on ${osName} ${alfaArch}"); // loads config file which maps the install keys to the tags var configFile = await TomlDocument.load(argResults['config']); @@ -189,7 +190,7 @@ void main(List args) async { arguments = ['-u', user]; } - arguments.addAll(['--preserve-env=ALFA_USER', '--', '/bin/bash']); + arguments.addAll(['--preserve-env=ALFA_USER,ALFA_ARCH', '--', '/bin/bash']); } arguments.addAll(['-euc', command]); diff --git a/functions.sh b/functions.sh index 03dcd62..712836a 100755 --- a/functions.sh +++ b/functions.sh @@ -4,6 +4,7 @@ # rather "install_brew". # To access the list of "options" in the config.toml file you pass to the installer, use the "$@" variable. # To access the user that called the installer, do not user the environment variable "$SUDO_USER", but rather use "$ALFA_USER". +# To access the uname -m output (system architecture), you can use the environment variable "$ALFA_ARCH" create_git_config() { # sets up git config name and email @@ -217,14 +218,14 @@ install_anaconda3_common() { install_anaconda3_macos() { # installs anaconda3 echo "Installing Anaconda3..." - curl "${1:-https://repo.anaconda.com/archive/Anaconda3-2022.05-MacOSX-x86_64.sh}" -o ~/anaconda3.sh + curl "${1:-https://repo.anaconda.com/archive/Anaconda3-2022.05-MacOSX-${ALFA_ARCH}.sh}" -o ~/anaconda3.sh install_anaconda3_common } install_anaconda3_linux() { # installs anaconda3 echo "Installing Anaconda3..." - curl "${1:-https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh}" -o ~/anaconda3.sh + curl "${1:-https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-${ALFA_ARCH}.sh}" -o ~/anaconda3.sh install_anaconda3_common } diff --git a/install.sh b/install.sh index 075363b..fa8ac6e 100755 --- a/install.sh +++ b/install.sh @@ -23,6 +23,8 @@ else exit 1 fi +export ALFA_ARCH="$unameMachine" + # runs the alfa command depending upon if sudo exists if ! command -v "sudo" > /dev/null 2>&1; then # sudo command doesn't exist @@ -39,7 +41,7 @@ else while :; do sudo -v; sleep 59; done & loopPid="$!" - export ALFA_USER="${SUDO_USER:-${USER:-}}"; sudo --preserve-env=ALFA_USER ./$alfaCommand "$@" + export ALFA_USER="${SUDO_USER:-${USER:-}}"; sudo --preserve-env=ALFA_USER,ALFA_ARCH ./$alfaCommand "$@" trap 'trap - SIGTERM && kill $(pgrep -P $loopPid) $loopPid' SIGINT SIGTERM EXIT