From 17f8c15973faefe141eb4fc5486097fbf38c0c58 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Wed, 26 Jun 2024 11:28:11 +0200 Subject: [PATCH 1/7] oblt-cli/setup: Add version-file input --- .github/workflows/test-oblt-cli-setup.yml | 35 ++++++++++++++++++++++- .oblt-cli-version | 1 + oblt-cli/setup/README.md | 1 + oblt-cli/setup/action.yml | 4 +++ oblt-cli/setup/download.sh | 11 +++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .oblt-cli-version diff --git a/.github/workflows/test-oblt-cli-setup.yml b/.github/workflows/test-oblt-cli-setup.yml index c3f3d0f9..e6b25919 100644 --- a/.github/workflows/test-oblt-cli-setup.yml +++ b/.github/workflows/test-oblt-cli-setup.yml @@ -12,13 +12,46 @@ permissions: jobs: test: + needs: + - version + - version-file + - default-version + runs-on: ubuntu-latest + steps: + - id: check + uses: elastic/oblt-actions/check-dependent-jobs@v1 + with: + jobs: ${{ toJSON(needs) }} + - run: ${{ steps.check.outputs.is-success }} + + version: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./oblt-cli/setup with: + version: 7.2.2 github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} + - run: | + version=$(oblt-cli version 2>&1) + [[ "$version" == *"version 7.2.2"* ]] + version-file: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./oblt-cli/setup + with: + github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} + version-file: .oblt-cli-version + - run: | + version=$(oblt-cli version 2>&1) + [[ "$version" == *"version 7.2.5"* ]] + default-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - uses: ./oblt-cli/setup with: github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} - - run: oblt-cli version + - run: | + oblt-cli version diff --git a/.oblt-cli-version b/.oblt-cli-version new file mode 100644 index 00000000..8aea167e --- /dev/null +++ b/.oblt-cli-version @@ -0,0 +1 @@ +7.2.5 diff --git a/oblt-cli/setup/README.md b/oblt-cli/setup/README.md index 14ccc920..6266472c 100644 --- a/oblt-cli/setup/README.md +++ b/oblt-cli/setup/README.md @@ -15,6 +15,7 @@ Setup oblt-cli for use in GitHub Actions workflows. | `slack-channel` | The slack channel to notify the status. | `false` | `#observablt-bots` | | `username` | Username to show in the deployments with oblt-cli, format: [a-z0-9] | `false` | `obltmachine` | | `version` | Install a specific version of oblt-cli | `false` | `7.2.2` | +| `version-file` | The file to read the version from. E.g. .oblt-cli-version | `false` | ` ` | ## Usage diff --git a/oblt-cli/setup/action.yml b/oblt-cli/setup/action.yml index 119feca3..499e06a5 100644 --- a/oblt-cli/setup/action.yml +++ b/oblt-cli/setup/action.yml @@ -19,6 +19,9 @@ inputs: description: "Install a specific version of oblt-cli" default: "7.2.2" required: false + version-file: + description: "The file to read the version from. E.g. .oblt-cli-version" + required: false runs: using: composite @@ -28,6 +31,7 @@ runs: env: GH_TOKEN: ${{ inputs.github-token }} OBLT_CLI_VERSION: ${{ inputs.version }} + OBLT_CLI_VERSION_FILE: ${{ inputs.version-file }} shell: bash - name: Configure oblt-cli run: > diff --git a/oblt-cli/setup/download.sh b/oblt-cli/setup/download.sh index e7e2da6e..38dbf965 100755 --- a/oblt-cli/setup/download.sh +++ b/oblt-cli/setup/download.sh @@ -29,6 +29,17 @@ else exit 1 fi +OBLT_CLI_VERSION_FILE=${OBLT_CLI_VERSION_FILE:-} + +if [[ -n "${OBLT_CLI_VERSION_FILE}" ]]; then + if [[ -f "${OBLT_CLI_VERSION_FILE}" ]]; then + OBLT_CLI_VERSION=$(< "${OBLT_CLI_VERSION_FILE}" tr -d '[:space:]') + else + echo "[ERROR] ${OBLT_CLI_VERSION_FILE} file not found." + exit 1 + fi +fi + # Downloads the latest release if OBLT_CLI_VERSION is not set gh release download "${OBLT_CLI_VERSION}" \ --skip-existing \ From 51a15db8bc4815584c730afc024d6d24139201df Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Wed, 26 Jun 2024 16:12:28 +0200 Subject: [PATCH 2/7] Add .tool-versions support --- .../oblt-cli/.oblt-cli-version | 0 .ci/oblt-cli/.tool-versions | 3 +++ .github/workflows/test-oblt-cli-setup.yml | 14 +++++++++++++- oblt-cli/setup/README.md | 14 +++++++------- oblt-cli/setup/action.yml | 2 +- oblt-cli/setup/download.sh | 6 +++++- 6 files changed, 29 insertions(+), 10 deletions(-) rename .oblt-cli-version => .ci/oblt-cli/.oblt-cli-version (100%) create mode 100644 .ci/oblt-cli/.tool-versions diff --git a/.oblt-cli-version b/.ci/oblt-cli/.oblt-cli-version similarity index 100% rename from .oblt-cli-version rename to .ci/oblt-cli/.oblt-cli-version diff --git a/.ci/oblt-cli/.tool-versions b/.ci/oblt-cli/.tool-versions new file mode 100644 index 00000000..387eae7a --- /dev/null +++ b/.ci/oblt-cli/.tool-versions @@ -0,0 +1,3 @@ +oblt-cli 7.2.5 +ruby 2.5.3 +nodejs 10.15.0 diff --git a/.github/workflows/test-oblt-cli-setup.yml b/.github/workflows/test-oblt-cli-setup.yml index e6b25919..dd84cd04 100644 --- a/.github/workflows/test-oblt-cli-setup.yml +++ b/.github/workflows/test-oblt-cli-setup.yml @@ -42,7 +42,7 @@ jobs: - uses: ./oblt-cli/setup with: github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} - version-file: .oblt-cli-version + version-file: .ci/oblt-cli/.oblt-cli-version - run: | version=$(oblt-cli version 2>&1) [[ "$version" == *"version 7.2.5"* ]] @@ -55,3 +55,15 @@ jobs: github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} - run: | oblt-cli version + + tools-versions: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./oblt-cli/setup + with: + github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} + version-file: .ci/oblt-cli/.tool-versions + - run: | + version=$(oblt-cli version 2>&1) + [[ "$version" == *"version 7.2.5"* ]] diff --git a/oblt-cli/setup/README.md b/oblt-cli/setup/README.md index 6266472c..31ecc90b 100644 --- a/oblt-cli/setup/README.md +++ b/oblt-cli/setup/README.md @@ -9,13 +9,13 @@ Setup oblt-cli for use in GitHub Actions workflows. ## Inputs -| Name | Description | Required | Default | -|-----------------|---------------------------------------------------------------------|----------|--------------------| -| `github-token` | The GitHub access token. | `true` | ` ` | -| `slack-channel` | The slack channel to notify the status. | `false` | `#observablt-bots` | -| `username` | Username to show in the deployments with oblt-cli, format: [a-z0-9] | `false` | `obltmachine` | -| `version` | Install a specific version of oblt-cli | `false` | `7.2.2` | -| `version-file` | The file to read the version from. E.g. .oblt-cli-version | `false` | ` ` | +| Name | Description | Required | Default | +|-----------------|-----------------------------------------------------------------------------|----------|--------------------| +| `github-token` | The GitHub access token. | `true` | ` ` | +| `slack-channel` | The slack channel to notify the status. | `false` | `#observablt-bots` | +| `username` | Username to show in the deployments with oblt-cli, format: [a-z0-9] | `false` | `obltmachine` | +| `version` | Install a specific version of oblt-cli | `false` | `7.2.2` | +| `version-file` | The file to read the version from. E.g. .oblt-cli-version or .tool-versions | `false` | ` ` | ## Usage diff --git a/oblt-cli/setup/action.yml b/oblt-cli/setup/action.yml index 499e06a5..be5ab212 100644 --- a/oblt-cli/setup/action.yml +++ b/oblt-cli/setup/action.yml @@ -20,7 +20,7 @@ inputs: default: "7.2.2" required: false version-file: - description: "The file to read the version from. E.g. .oblt-cli-version" + description: "The file to read the version from. E.g. .oblt-cli-version or .tool-versions" required: false runs: diff --git a/oblt-cli/setup/download.sh b/oblt-cli/setup/download.sh index 38dbf965..b88964c5 100755 --- a/oblt-cli/setup/download.sh +++ b/oblt-cli/setup/download.sh @@ -33,7 +33,11 @@ OBLT_CLI_VERSION_FILE=${OBLT_CLI_VERSION_FILE:-} if [[ -n "${OBLT_CLI_VERSION_FILE}" ]]; then if [[ -f "${OBLT_CLI_VERSION_FILE}" ]]; then - OBLT_CLI_VERSION=$(< "${OBLT_CLI_VERSION_FILE}" tr -d '[:space:]') + if [[ "$(basename "$OBLT_CLI_VERSION_FILE")" == ".tool-versions" ]]; then + OBLT_CLI_VERSION=$(grep "oblt-cli" "${OBLT_CLI_VERSION_FILE}" | awk '{ print $2 }') + else + OBLT_CLI_VERSION=$(< "${OBLT_CLI_VERSION_FILE}" tr -d '[:space:]') + fi else echo "[ERROR] ${OBLT_CLI_VERSION_FILE} file not found." exit 1 From 7c3a9bf458b6c489399c2606120e9a4ea2bb68ac Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Wed, 26 Jun 2024 16:16:00 +0200 Subject: [PATCH 3/7] Handle comments --- .ci/oblt-cli/.tool-versions | 3 ++- oblt-cli/setup/download.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.ci/oblt-cli/.tool-versions b/.ci/oblt-cli/.tool-versions index 387eae7a..d916c879 100644 --- a/.ci/oblt-cli/.tool-versions +++ b/.ci/oblt-cli/.tool-versions @@ -1,3 +1,4 @@ -oblt-cli 7.2.5 +oblt-cli 7.2.5 # This is a comment that contains oblt-cli +# This is another comment that contains oblt-cli ruby 2.5.3 nodejs 10.15.0 diff --git a/oblt-cli/setup/download.sh b/oblt-cli/setup/download.sh index b88964c5..f43de5cf 100755 --- a/oblt-cli/setup/download.sh +++ b/oblt-cli/setup/download.sh @@ -34,7 +34,7 @@ OBLT_CLI_VERSION_FILE=${OBLT_CLI_VERSION_FILE:-} if [[ -n "${OBLT_CLI_VERSION_FILE}" ]]; then if [[ -f "${OBLT_CLI_VERSION_FILE}" ]]; then if [[ "$(basename "$OBLT_CLI_VERSION_FILE")" == ".tool-versions" ]]; then - OBLT_CLI_VERSION=$(grep "oblt-cli" "${OBLT_CLI_VERSION_FILE}" | awk '{ print $2 }') + OBLT_CLI_VERSION=$(grep "^oblt-cli" "${OBLT_CLI_VERSION_FILE}" | awk '{ print $2 }') else OBLT_CLI_VERSION=$(< "${OBLT_CLI_VERSION_FILE}" tr -d '[:space:]') fi From f4b3544fcab29dc91455c10072612cb05615c4ec Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Wed, 26 Jun 2024 16:20:27 +0200 Subject: [PATCH 4/7] Remove files --- .ci/oblt-cli/.oblt-cli-version | 1 - .ci/oblt-cli/.tool-versions | 4 ---- .github/workflows/test-oblt-cli-setup.yml | 15 +++++++++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) delete mode 100644 .ci/oblt-cli/.oblt-cli-version delete mode 100644 .ci/oblt-cli/.tool-versions diff --git a/.ci/oblt-cli/.oblt-cli-version b/.ci/oblt-cli/.oblt-cli-version deleted file mode 100644 index 8aea167e..00000000 --- a/.ci/oblt-cli/.oblt-cli-version +++ /dev/null @@ -1 +0,0 @@ -7.2.5 diff --git a/.ci/oblt-cli/.tool-versions b/.ci/oblt-cli/.tool-versions deleted file mode 100644 index d916c879..00000000 --- a/.ci/oblt-cli/.tool-versions +++ /dev/null @@ -1,4 +0,0 @@ -oblt-cli 7.2.5 # This is a comment that contains oblt-cli -# This is another comment that contains oblt-cli -ruby 2.5.3 -nodejs 10.15.0 diff --git a/.github/workflows/test-oblt-cli-setup.yml b/.github/workflows/test-oblt-cli-setup.yml index dd84cd04..f653fbcc 100644 --- a/.github/workflows/test-oblt-cli-setup.yml +++ b/.github/workflows/test-oblt-cli-setup.yml @@ -39,10 +39,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup version file + run: | + echo "7.2.5" > .oblt-cli-version - uses: ./oblt-cli/setup with: github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} - version-file: .ci/oblt-cli/.oblt-cli-version + version-file: .oblt-cli-version - run: | version=$(oblt-cli version 2>&1) [[ "$version" == *"version 7.2.5"* ]] @@ -60,10 +63,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup version file + run: | + cat < .tool-versions + oblt-cli 7.2.5 # This is a comment that contains oblt-cli + # This is another comment that contains oblt-cli + ruby 2.5.3 + nodejs 10.15.0 + EOF - uses: ./oblt-cli/setup with: github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} - version-file: .ci/oblt-cli/.tool-versions + version-file: .tool-versions - run: | version=$(oblt-cli version 2>&1) [[ "$version" == *"version 7.2.5"* ]] From 05e35a7dd0f10c226d5026685eb86b21c907c20c Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Wed, 26 Jun 2024 16:21:39 +0200 Subject: [PATCH 5/7] Add step names --- .github/workflows/test-oblt-cli-setup.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-oblt-cli-setup.yml b/.github/workflows/test-oblt-cli-setup.yml index f653fbcc..6811f036 100644 --- a/.github/workflows/test-oblt-cli-setup.yml +++ b/.github/workflows/test-oblt-cli-setup.yml @@ -32,7 +32,8 @@ jobs: with: version: 7.2.2 github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} - - run: | + - name: Verify oblt-cli version + run: | version=$(oblt-cli version 2>&1) [[ "$version" == *"version 7.2.2"* ]] version-file: @@ -46,7 +47,8 @@ jobs: with: github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} version-file: .oblt-cli-version - - run: | + - name: Verify oblt-cli version + run: | version=$(oblt-cli version 2>&1) [[ "$version" == *"version 7.2.5"* ]] default-version: @@ -56,7 +58,8 @@ jobs: - uses: ./oblt-cli/setup with: github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} - - run: | + - name: Verify oblt-cli version + run: | oblt-cli version tools-versions: @@ -75,6 +78,7 @@ jobs: with: github-token: ${{ secrets.OBLT_CLI_GITHUB_TOKEN }} version-file: .tool-versions - - run: | + - name: Verify oblt-cli version + run: | version=$(oblt-cli version 2>&1) [[ "$version" == *"version 7.2.5"* ]] From ab9e38448c9e872ecaed6805fa523379dc665012 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Wed, 26 Jun 2024 16:24:50 +0200 Subject: [PATCH 6/7] Better input description --- oblt-cli/setup/README.md | 14 +++++++------- oblt-cli/setup/action.yml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/oblt-cli/setup/README.md b/oblt-cli/setup/README.md index 31ecc90b..cf2fdb1a 100644 --- a/oblt-cli/setup/README.md +++ b/oblt-cli/setup/README.md @@ -9,13 +9,13 @@ Setup oblt-cli for use in GitHub Actions workflows. ## Inputs -| Name | Description | Required | Default | -|-----------------|-----------------------------------------------------------------------------|----------|--------------------| -| `github-token` | The GitHub access token. | `true` | ` ` | -| `slack-channel` | The slack channel to notify the status. | `false` | `#observablt-bots` | -| `username` | Username to show in the deployments with oblt-cli, format: [a-z0-9] | `false` | `obltmachine` | -| `version` | Install a specific version of oblt-cli | `false` | `7.2.2` | -| `version-file` | The file to read the version from. E.g. .oblt-cli-version or .tool-versions | `false` | ` ` | +| Name | Description | Required | Default | +|-----------------|--------------------------------------------------------------------------------------------------------------------------------------|----------|--------------------| +| `github-token` | The GitHub access token. | `true` | ` ` | +| `slack-channel` | The slack channel to notify the status. | `false` | `#observablt-bots` | +| `username` | Username to show in the deployments with oblt-cli, format: [a-z0-9] | `false` | `obltmachine` | +| `version` | Install a specific version of oblt-cli | `false` | `7.2.2` | +| `version-file` | The file to read the version from. E.g. `.oblt-cli-version`` or `.tool-versions`. This option takes precedence over `version`. | `false` | ` ` | ## Usage diff --git a/oblt-cli/setup/action.yml b/oblt-cli/setup/action.yml index be5ab212..b6b33d1e 100644 --- a/oblt-cli/setup/action.yml +++ b/oblt-cli/setup/action.yml @@ -20,7 +20,7 @@ inputs: default: "7.2.2" required: false version-file: - description: "The file to read the version from. E.g. .oblt-cli-version or .tool-versions" + description: "The file to read the version from. E.g. `.oblt-cli-version`` or `.tool-versions`. This option takes precedence over `version`." required: false runs: From c9e5bfa9ec2ee3be831ed3cda31119193399a633 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Wed, 26 Jun 2024 16:25:26 +0200 Subject: [PATCH 7/7] Fix description --- oblt-cli/setup/README.md | 14 +++++++------- oblt-cli/setup/action.yml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/oblt-cli/setup/README.md b/oblt-cli/setup/README.md index cf2fdb1a..df23d41a 100644 --- a/oblt-cli/setup/README.md +++ b/oblt-cli/setup/README.md @@ -9,13 +9,13 @@ Setup oblt-cli for use in GitHub Actions workflows. ## Inputs -| Name | Description | Required | Default | -|-----------------|--------------------------------------------------------------------------------------------------------------------------------------|----------|--------------------| -| `github-token` | The GitHub access token. | `true` | ` ` | -| `slack-channel` | The slack channel to notify the status. | `false` | `#observablt-bots` | -| `username` | Username to show in the deployments with oblt-cli, format: [a-z0-9] | `false` | `obltmachine` | -| `version` | Install a specific version of oblt-cli | `false` | `7.2.2` | -| `version-file` | The file to read the version from. E.g. `.oblt-cli-version`` or `.tool-versions`. This option takes precedence over `version`. | `false` | ` ` | +| Name | Description | Required | Default | +|-----------------|-------------------------------------------------------------------------------------------------------------------------------|----------|--------------------| +| `github-token` | The GitHub access token. | `true` | ` ` | +| `slack-channel` | The slack channel to notify the status. | `false` | `#observablt-bots` | +| `username` | Username to show in the deployments with oblt-cli, format: [a-z0-9] | `false` | `obltmachine` | +| `version` | Install a specific version of oblt-cli | `false` | `7.2.2` | +| `version-file` | The file to read the version from. E.g. `.oblt-cli-version` or `.tool-versions`. This option takes precedence over `version`. | `false` | ` ` | ## Usage diff --git a/oblt-cli/setup/action.yml b/oblt-cli/setup/action.yml index b6b33d1e..742279b1 100644 --- a/oblt-cli/setup/action.yml +++ b/oblt-cli/setup/action.yml @@ -20,7 +20,7 @@ inputs: default: "7.2.2" required: false version-file: - description: "The file to read the version from. E.g. `.oblt-cli-version`` or `.tool-versions`. This option takes precedence over `version`." + description: "The file to read the version from. E.g. `.oblt-cli-version` or `.tool-versions`. This option takes precedence over `version`." required: false runs: