From d88a23588385c4c4ca6eb0f75791dd98ef04e2da Mon Sep 17 00:00:00 2001 From: rishflab Date: Wed, 3 Mar 2021 16:36:51 +1100 Subject: [PATCH 1/3] Use gtar to create release archive tar was producing an archived that binary that was failing to execute on developer machines. Since gtar is not available on windows or ubuntu, the windows and ubuntu releases was removed. --- .github/actions/create-release-archive/action.yml | 2 +- .github/workflows/release-cli.yml | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/actions/create-release-archive/action.yml b/.github/actions/create-release-archive/action.yml index 45934d0d..c1dd5d05 100644 --- a/.github/actions/create-release-archive/action.yml +++ b/.github/actions/create-release-archive/action.yml @@ -35,4 +35,4 @@ runs: - name: Make archive shell: bash - run: tar -C ./target/${{ inputs.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} ${{ inputs.binary }} \ No newline at end of file + run: gtar -C ./target/${{ inputs.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} ${{ inputs.binary }} diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 13c4efb8..a79afd2b 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -10,12 +10,8 @@ jobs: strategy: matrix: include: - - target: x86_64-unknown-linux-gnu - os: ubuntu-latest - target: x86_64-apple-darwin os: macos-latest - - target: x86_64-pc-windows-msvc - os: windows-latest runs-on: ${{ matrix.os }} steps: - name: Checkout tagged commit From 13764161a309a43ef791df4986645d6fd0cacd7d Mon Sep 17 00:00:00 2001 From: rishflab Date: Wed, 3 Mar 2021 23:06:12 +1100 Subject: [PATCH 2/3] Add create release archive action for windows Windows users may not have a tar extractor installed by default so 7z was used to create a zip archive. I attempted to add the action names to the strategy matrix so we dont need if statements to choose the appropriate create release archive action but github did not like when I passed a field under strategy.matrix.include into steps.uses. --- .../create-release-archive-windows/action.yml | 40 +++++++++++++++++++ .github/workflows/release-cli.yml | 24 +++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/actions/create-release-archive-windows/action.yml diff --git a/.github/actions/create-release-archive-windows/action.yml b/.github/actions/create-release-archive-windows/action.yml new file mode 100644 index 00000000..2a126e26 --- /dev/null +++ b/.github/actions/create-release-archive-windows/action.yml @@ -0,0 +1,40 @@ +name: Create release archive +description: Creates a zip archive for a release binary +inputs: + version: + description: 'The version of the binary' + required: true + binary: + description: 'The name of the binary to pack into the archive' + required: true + target: + description: 'The target triple, used to find the binary; pass it if the compilation was done with the `--target` argument' + required: false +outputs: + archive: + description: 'The name of the archive' + value: ${{ steps.create-archive-name.outputs.archive }} +runs: + using: "composite" + steps: + - id: create-archive-name + shell: python # Use python to have a prettier name for the archive on Windows. + run: | + import platform + os_info = platform.uname() + + arch = os_info.machine + + if "${{ inputs.target }}": + triple = "${{ inputs.target }}".split("-") + arch = triple[0] + + archive_name=f'${{ inputs.binary }}_${{ inputs.version }}_{os_info.system}_{arch}.zip' + + print(f'::set-output name=archive::{archive_name}') + + - name: Make archive + shell: bash + run: | + cp -p ./target/${{ matrix.target }}/release/${{ inputs.binary }} ${{ inputs.binary }}.exe + 7z a -tzip ${{ steps.create-archive-name.outputs.archive }} ${{ inputs.binary }}.exe diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index a79afd2b..cac73d33 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -12,6 +12,8 @@ jobs: include: - target: x86_64-apple-darwin os: macos-latest + - target: x86_64-pc-windows-msvc + os: windows-latest runs-on: ${{ matrix.os }} steps: - name: Checkout tagged commit @@ -31,8 +33,18 @@ jobs: with: python-version: '3.x' + - name: Create release archive + id: create-archive-windows + if: contains(matrix.os, 'windows') + uses: ./.github/actions/create-release-archive-windows + with: + binary: swap_cli + version: ${{ github.event.release.tag_name }} + target: ${{ matrix.target }} + - name: Create release archive id: create-archive + if: contains(matrix.os, 'macos') || contains(matrix.os, 'ubuntu') uses: ./.github/actions/create-release-archive with: binary: swap_cli @@ -40,6 +52,18 @@ jobs: target: ${{ matrix.target }} - name: Upload ${{ matrix.os }} release binary + if: contains(matrix.os, 'windows') + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BOTTY_GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./${{ steps.create-archive-windows.outputs.archive }} + asset_name: ${{ steps.create-archive-windows.outputs.archive }} + asset_content_type: application/gzip + + - name: Upload ${{ matrix.os }} release binary + if: contains(matrix.os, 'macos') || contains(matrix.os, 'ubuntu') uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.BOTTY_GITHUB_TOKEN }} From 95b1558c8eb33e363c819eabaed1c49960cc0a20 Mon Sep 17 00:00:00 2001 From: rishflab Date: Wed, 3 Mar 2021 23:39:45 +1100 Subject: [PATCH 3/3] Add create release archive action for ubuntu gtar is not installed on ubuntu so tar has to be used --- .../{ => macos}/action.yml | 0 .../create-release-archive/ubuntu/action.yml | 38 ++++++++++++++++ .../windows}/action.yml | 0 .github/workflows/release-cli.yml | 44 ++++++++++++++----- 4 files changed, 71 insertions(+), 11 deletions(-) rename .github/actions/create-release-archive/{ => macos}/action.yml (100%) create mode 100644 .github/actions/create-release-archive/ubuntu/action.yml rename .github/actions/{create-release-archive-windows => create-release-archive/windows}/action.yml (100%) diff --git a/.github/actions/create-release-archive/action.yml b/.github/actions/create-release-archive/macos/action.yml similarity index 100% rename from .github/actions/create-release-archive/action.yml rename to .github/actions/create-release-archive/macos/action.yml diff --git a/.github/actions/create-release-archive/ubuntu/action.yml b/.github/actions/create-release-archive/ubuntu/action.yml new file mode 100644 index 00000000..13b6c99c --- /dev/null +++ b/.github/actions/create-release-archive/ubuntu/action.yml @@ -0,0 +1,38 @@ +name: Create release archive +description: Creates a tar archive for a release binary +inputs: + version: + description: 'The version of the binary' + required: true + binary: + description: 'The name of the binary to pack into the archive' + required: true + target: + description: 'The target triple, used to find the binary; pass it if the compilation was done with the `--target` argument' + required: false +outputs: + archive: + description: 'The name of the archive' + value: ${{ steps.create-archive-name.outputs.archive }} +runs: + using: "composite" + steps: + - id: create-archive-name + shell: python # Use python to have a prettier name for the archive on Windows. + run: | + import platform + os_info = platform.uname() + + arch = os_info.machine + + if "${{ inputs.target }}": + triple = "${{ inputs.target }}".split("-") + arch = triple[0] + + archive_name=f'${{ inputs.binary }}_${{ inputs.version }}_{os_info.system}_{arch}.tar' + + print(f'::set-output name=archive::{archive_name}') + + - name: Make archive + shell: bash + run: tar -C ./target/${{ inputs.target }}/release --create --file=${{ steps.create-archive-name.outputs.archive }} ${{ inputs.binary }} diff --git a/.github/actions/create-release-archive-windows/action.yml b/.github/actions/create-release-archive/windows/action.yml similarity index 100% rename from .github/actions/create-release-archive-windows/action.yml rename to .github/actions/create-release-archive/windows/action.yml diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index cac73d33..9d0c0b7a 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -10,6 +10,8 @@ jobs: strategy: matrix: include: + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest - target: x86_64-apple-darwin os: macos-latest - target: x86_64-pc-windows-msvc @@ -33,25 +35,34 @@ jobs: with: python-version: '3.x' - - name: Create release archive + - name: Create windows release archive id: create-archive-windows if: contains(matrix.os, 'windows') - uses: ./.github/actions/create-release-archive-windows + uses: ./.github/actions/create-release-archive/windows with: binary: swap_cli version: ${{ github.event.release.tag_name }} target: ${{ matrix.target }} - - name: Create release archive - id: create-archive - if: contains(matrix.os, 'macos') || contains(matrix.os, 'ubuntu') - uses: ./.github/actions/create-release-archive + - name: Create macos release archive + id: create-archive-macos + if: contains(matrix.os, 'macos') + uses: ./.github/actions/create-release-archive/macos with: binary: swap_cli version: ${{ github.event.release.tag_name }} target: ${{ matrix.target }} - - name: Upload ${{ matrix.os }} release binary + - name: Create ubuntu release archive + id: create-archive-ubuntu + if: contains(matrix.os, 'ubuntu') + uses: ./.github/actions/create-release-archive/ubuntu + with: + binary: swap_cli + version: ${{ github.event.release.tag_name }} + target: ${{ matrix.target }} + + - name: Upload windows release binary if: contains(matrix.os, 'windows') uses: actions/upload-release-asset@v1 env: @@ -62,13 +73,24 @@ jobs: asset_name: ${{ steps.create-archive-windows.outputs.archive }} asset_content_type: application/gzip - - name: Upload ${{ matrix.os }} release binary - if: contains(matrix.os, 'macos') || contains(matrix.os, 'ubuntu') + - name: Upload macos release binary + if: contains(matrix.os, 'macos') + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.BOTTY_GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./${{ steps.create-archive-macos.outputs.archive }} + asset_name: ${{ steps.create-archive-macos.outputs.archive }} + asset_content_type: application/gzip + + - name: Upload ubuntu release binary + if: contains(matrix.os, 'ubuntu') uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.BOTTY_GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} - asset_path: ./${{ steps.create-archive.outputs.archive }} - asset_name: ${{ steps.create-archive.outputs.archive }} + asset_path: ./${{ steps.create-archive-ubuntu.outputs.archive }} + asset_name: ${{ steps.create-archive-ubuntu.outputs.archive }} asset_content_type: application/gzip