From 5adf39651a0ab0ea7291385c3084135e7db8267a Mon Sep 17 00:00:00 2001 From: DeveloperC286 Date: Fri, 29 Dec 2023 15:48:40 +0000 Subject: [PATCH] BUILD: WORKING COMMIT - DELETE --- .github/workflows/release-artifacts.yml | 28 +++++++++++++++++++++++++ Earthfile | 17 +++++++++++++++ ci/release-artifacts.sh | 11 ++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .github/workflows/release-artifacts.yml create mode 100644 ci/release-artifacts.sh diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml new file mode 100644 index 0000000..06b0ff7 --- /dev/null +++ b/.github/workflows/release-artifacts.yml @@ -0,0 +1,28 @@ +name: Continuous Delivery (CD) + +# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs +permissions: + contents: write + +on: + release: + types: + - published + +env: + # Forcing Earthly to use colours, to make reading output easier. + FORCE_COLOR: 1 + +jobs: + release-artifacts: + name: Release artifacts. + runs-on: ubuntu-latest + steps: + - name: Download Earthly v0.7.17. + run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.17/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" + - name: Checkout code. + uses: actions/checkout@v3 + - name: Release artifacts. + run: earthly --ci --secret GH_TOKEN +release-artifacts + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by GitHub Actions. diff --git a/Earthfile b/Earthfile index 1f73ebb..993c8f8 100644 --- a/Earthfile +++ b/Earthfile @@ -192,3 +192,20 @@ unit-test: DO +INSTALL_DEPENDENCIES DO +COPY_SOURCECODE RUN ./ci/unit-test.sh + + +INSTALL_GITHUB_CLI: + COMMAND + ENV GITHUB_CLI_VERSION=2.30.0 + RUN wget "https://github.com/cli/cli/releases/download/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_amd64.tar.gz" + RUN tar -xzvf "gh_${GITHUB_CLI_VERSION}_linux_amd64.tar.gz" + RUN cp "./gh_${GITHUB_CLI_VERSION}_linux_amd64/bin/gh" /bin/gh + + +release-artifacts: + FROM +ubuntu-base + RUN apt-get install wget jq -y + DO +INSTALL_GITHUB_CLI + COPY +compile/dist ./dist + DO +COPY_CI_DATA + RUN --secret GH_TOKEN ./ci/release-artifacts.sh diff --git a/ci/release-artifacts.sh b/ci/release-artifacts.sh new file mode 100644 index 0000000..40649b4 --- /dev/null +++ b/ci/release-artifacts.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +set -o errexit +set -o xtrace + +for row in $(jq -c '.[]' "dist/artifacts.json"); do + path=$(echo "${row}" | jq -r '.path') + name=$(echo "${path}" | cut -d '/' -f 2) + + echo "gh release upload TAG ${path}%#%${name}" +done