diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 5a574e71..3bb11836 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -8,8 +8,12 @@ on: jobs: install: + strategy: + matrix: + runner: + - ubuntu-latest name: test action - runs-on: ubuntu-latest + runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 - uses: kayac/ecspresso@v0 @@ -56,3 +60,28 @@ jobs: version: v2.0.4 - run: | ecspresso version 2>&1 | fgrep v2.0.4 + + install_on_arm: + strategy: + matrix: + runner: + - buildjet-2vcpu-ubuntu-2204-arm + name: test action + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v4 + - uses: kayac/ecspresso@v2-action-testing + with: + version: latest + - run: | + ecspresso version 2>&1 | fgrep v2. + - uses: kayac/ecspresso@v2-action-testing + with: + version: v2.0.4 + - run: | + ecspresso version 2>&1 | fgrep v2.0.4 + - uses: kayac/ecspresso@v2-action-testing + with: + version-file: tests/.ecspresso-version + - run: | + ecspresso version 2>&1 | fgrep v2.0.0 diff --git a/action.yml b/action.yml index 916255f9..182eadd5 100644 --- a/action.yml +++ b/action.yml @@ -18,19 +18,34 @@ runs: github_token: ${{ inputs.github-token }} run: | set -e + ARCH=$(uname -m) + if [ "${ARCH}" = "x86_64" ]; then + GOARCH="amd64" + elif [ "${ARCH}" = "aarch64" ]; then + GOARCH="arm64" + else + echo "Unsupported architecture: ${ARCH}" + exit 1 + fi + VERSION="${{ inputs.version }}" if [ -n "${{ inputs.version-file }}" ]; then VERSION="v$(cat ${{ inputs.version-file }})" fi + + echo "VERSION=${VERSION} GOARCH=${GOARCH}" + api_request_args=("-sS") if [[ -n "$github_token" ]]; then api_request_args=("${api_request_args[@]}" -H "authorization: token $github_token") fi if [ "${VERSION}" = "latest" ]; then - DOWNLOAD_URL=$(curl "${api_request_args[@]}" https://api.github.com/repos/kayac/ecspresso/releases | jq -r '[.[]|select(.tag_name > "v2.0")|select(.prerelease==false)][0].assets[].browser_download_url|select(match("linux.amd64."))') + DOWNLOAD_URL=$(curl "${api_request_args[@]}" https://api.github.com/repos/kayac/ecspresso/releases \ + | jq --arg matcher "linux.${GOARCH}." -r '[.[]|select(.tag_name > "v2.0")|select(.prerelease==false)][0].assets[].browser_download_url|select(match($matcher))') else - DOWNLOAD_URL=https://github.com/kayac/ecspresso/releases/download/${VERSION}/ecspresso_${VERSION:1}_linux_amd64.tar.gz + DOWNLOAD_URL=https://github.com/kayac/ecspresso/releases/download/${VERSION}/ecspresso_${VERSION:1}_linux_${GOARCH}.tar.gz fi + echo "DOWNLOAD_URL=${DOWNLOAD_URL}" mkdir -p ${RUNNER_TOOL_CACHE}/ecspresso cd /tmp curl -sfLO ${DOWNLOAD_URL}