From 77d4aa243fb2b7f32cd336a5b710ae03bad0eb18 Mon Sep 17 00:00:00 2001 From: Krzysztof Bieganski Date: Mon, 24 Apr 2023 16:22:18 +0200 Subject: [PATCH] Use git ref for tagging releases (#19) This patch: - adds support for tagged releases to improve backwards compatibility and reduce breakage for users of this action - renames the `build_and_test` workflow to `release` - adds a warning to the `README` that this action is still very much in flux Signed-off-by: Krzysztof Bieganski --- .../{build_and_test.yml => release.yml} | 24 +++++++++++++++---- README.md | 16 +++++++++---- action.yml | 22 +++++++++++------ br2-external/external.desc | 2 +- 4 files changed, 46 insertions(+), 18 deletions(-) rename .github/workflows/{build_and_test.yml => release.yml} (68%) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/release.yml similarity index 68% rename from .github/workflows/build_and_test.yml rename to .github/workflows/release.yml index 20632e8..9f436d5 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Build and test +name: Release on: [push, workflow_dispatch, repository_dispatch] permissions: write-all @@ -9,17 +9,32 @@ jobs: permissions: pull-requests: read outputs: - build: ${{ steps.filter.outputs.build }} + build: ${{ steps.build-needed.outputs.build }} steps: - uses: actions/checkout@v3 - uses: dorny/paths-filter@v2 id: filter with: - base: ${{ github.ref }} + base: ${{ github.ref_name }} filters: | build: - 'br2-external/**' + + - name: check if release exists + id: check-release + run: | + # gh release view returns non-zero if no such release exists + echo "build=$(gh release view ${{ github.ref_name }} &> /dev/null && echo $? || echo $?)" >> $GITHUB_OUTPUT + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: check if build is needed + id: build-needed + run: | + # Step outputs apparently are strings, so we have to compare against literals to avoid silly JS type coercion issues. + echo "build=${{ steps.filter.outputs.build == 'true' || steps.check-release.outputs.build != '0' }}" >> $GITHUB_OUTPUT + build: runs-on: ubuntu-latest needs: changes @@ -41,7 +56,7 @@ jobs: repo_token: "${{ github.token }}" file: images.tar.xz asset_name: images.tar.xz - tag: latest + tag: ${{ github.ref_name }} overwrite: true default-configuration-test: @@ -61,7 +76,6 @@ jobs: uses: ./ with: shared-dir: ./tests - image: https://github.com/${{ github.repository }}/releases/download/latest/images.tar.xz renode-run: | wget example.org gpiodetect diff --git a/README.md b/README.md index 2b40862..d6ce684 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ # renode-linux-runner-action -Copyright (c) 2022 [Antmicro](https://www.antmicro.com) +Copyright (c) 2022-2023 [Antmicro](https://www.antmicro.com) renode-linux-runner-action is a GitHub Action that can run scripts on Linux inside the Renode emulation. +> **Warning** +> This action is under heavy development. We will do our best to avoid breaking +> changes, but we cannot guarantee full backwards compatibility at this point. +> We recommend using the `v0` tag to minimize chances of breakage. If your +> workflow fails due to our changes, feel free to file an issue. + ## Emulated system The emulated system is based on the [Buildroot 2022.11.3](https://github.com/buildroot/buildroot/tree/2022.11.3) and it runs on the RISC-V/HiFive Unleashed platform in [Renode 1.13.3](https://github.com/renode/renode). @@ -27,7 +33,7 @@ It contains the Linux kernel configured with some emulated devices enabled and i ### Devices syntax ```yaml -- uses: antmicro/renode-linux-runner-action@main +- uses: antmicro/renode-linux-runner-action@v0 with: devices: | device1 param1 param2 param3 ... @@ -49,7 +55,7 @@ It contains the Linux kernel configured with some emulated devices enabled and i Running a single command using the `renode-run` parameter: ```yaml -- uses: antmicro/renode-linux-runner-action@main +- uses: antmicro/renode-linux-runner-action@v0 with: shared-dir: ./shared-dir renode-run: command_to_run @@ -59,7 +65,7 @@ Running a single command using the `renode-run` parameter: Running multiple commands works the same way as the standard `run` command: ```yaml -- uses: antmicro/renode-linux-runner-action@main +- uses: antmicro/renode-linux-runner-action@v0 with: shared-dir: ./shared-dir renode-run: | @@ -72,4 +78,4 @@ Running multiple commands works the same way as the standard `run` command: Multiple devices can also be specified this way. -The [renode-linux-runner-test](.github/workflows/build_and_test.yml) workflow contains an example usage of this action. +The [release](.github/workflows/release.yml) workflow contains an example usage of this action. diff --git a/action.yml b/action.yml index 5433f5e..14323a4 100644 --- a/action.yml +++ b/action.yml @@ -13,7 +13,7 @@ inputs: image: description: Compiled linux image source required: false - default: "https://github.com/antmicro/renode-linux-runner-action/releases/download/latest/images.tar.xz" + default: "" python-packages: description: Custom python packages that will be added to your shared dir required: false @@ -35,14 +35,22 @@ runs: - id: get-images run: | - if [ -f "${{ inputs.image }}" ] && [ $(realpath "${{ inputs.image }}") == "$(realpath ${{github.action_path}}/images.tar.xz)" ]; then \ - echo File already exists; \ - elif [ -f "${{ inputs.image }}" ]; then \ - cp "${{ inputs.image }}" ${{github.action_path}}/images.tar.xz; \ - else \ - wget -q --no-verbose "${{ inputs.image }}" -O ${{github.action_path}}/images.tar.xz; \ + if [ -z "$IMAGE" ]; then + IMAGE="https://github.com/$ACTION_REPO/releases/download/$ACTION_REF/images.tar.xz" + fi + if [ -f "$IMAGE" ] && [ $(realpath "$IMAGE") == "$(realpath ${{github.action_path}}/images.tar.xz)" ]; then + echo File already exists; + elif [ -f "$IMAGE" ]; then + cp "$IMAGE" ${{github.action_path}}/images.tar.xz; + else + wget -q --no-verbose "$IMAGE" -O ${{github.action_path}}/images.tar.xz; fi shell: bash + env: + IMAGE: ${{ inputs.image }} + # https://github.com/orgs/community/discussions/49245 + ACTION_REPO: ${{ github.action_repository || github.repository }} + ACTION_REF: ${{ github.action_ref || github.ref_name }} - id: decompress run: cd ${{github.action_path}} && tar xf images.tar.xz diff --git a/br2-external/external.desc b/br2-external/external.desc index a096f15..ffea684 100644 --- a/br2-external/external.desc +++ b/br2-external/external.desc @@ -1,2 +1,2 @@ name: SIFIVE_RENODE_CI -desc: Linux embedded instance for use in github actions \ No newline at end of file +desc: Linux embedded instance for use in github actions