From ccef82db1abb378566f155d0b62b4d97f137b0b3 Mon Sep 17 00:00:00 2001 From: Mariusz Kogen Date: Thu, 28 Dec 2023 17:57:37 +0100 Subject: [PATCH] Update workflows to latest versions (#108) --- .github/workflows/buildService.yml | 57 +++++------------ .github/workflows/releaseService.yml | 93 ++++++++++++++-------------- 2 files changed, 59 insertions(+), 91 deletions(-) diff --git a/.github/workflows/buildService.yml b/.github/workflows/buildService.yml index b40ee30..f013351 100644 --- a/.github/workflows/buildService.yml +++ b/.github/workflows/buildService.yml @@ -4,62 +4,33 @@ on: workflow_dispatch: pull_request: paths-ignore: ['*.md'] - branches: ['ci-build'] + branches: ['main', 'master'] push: paths-ignore: ['*.md'] - branches: ['ci-build'] + branches: ['main', 'master'] jobs: BuildPackage: runs-on: ubuntu-latest steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Set up Rust Toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - - name: Get StartOS Hash - run: echo "EMBASSYHASH=$(git ls-remote https://github.com/Start9Labs/start-os HEAD | awk '{ print $1}')" >> $GITHUB_ENV - - name: Cache Packages - uses: buildjet/cache@v3 - id: packageCache - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-c-lightning-${{ env.EMBASSYHASH }} - - name: Install Dependencies - run: | - sudo snap install yq deno - sudo apt-get install -y build-essential openssl libssl-dev libc6-dev clang libclang-dev ca-certificates + - name: Prepare StartOS SDK + uses: Start9Labs/sdk@v1 + - name: Checkout services repository uses: actions/checkout@v3 - - name: Install Package Manager - id: packageManager - if: steps.packageCache.outputs.cache-hit != 'true' - run: | - cd ~/ && git clone https://github.com/Start9Labs/start-os.git; - cd start-os; - git submodule update --init --recursive - cd backend; - export RUSTFLAGS=""; - export OS_ARCH=$(uname -m); - ./install-sdk.sh; - cargo install --git=https://github.com/Start9Labs/md-packer.git --branch=main; + - name: Build the service package + id: build run: | git submodule update --init --recursive - embassy-sdk init + start-sdk init make - mv c-lightning*s9pk ~/ + PACKAGE_ID=$(yq -oy ".id" manifest.*) + echo "::set-output name=package_id::$PACKAGE_ID" + shell: bash + - name: Upload .s9pk uses: actions/upload-artifact@v3 with: - name: c-lightning.s9pk - path: ~/*.s9pk + name: ${{ steps.build.outputs.package_id }}.s9pk + path: ./${{ steps.build.outputs.package_id }}.s9pk \ No newline at end of file diff --git a/.github/workflows/releaseService.yml b/.github/workflows/releaseService.yml index 1b54e7d..427d777 100644 --- a/.github/workflows/releaseService.yml +++ b/.github/workflows/releaseService.yml @@ -1,7 +1,6 @@ name: Release Service on: - workflow_dispatch: push: tags: - 'v*.*' @@ -9,66 +8,64 @@ on: jobs: ReleasePackage: runs-on: ubuntu-latest + permissions: + contents: write steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Set up Rust Toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - - name: Get StartOS Hash - run: echo "EMBASSYHASH=$(git ls-remote https://github.com/Start9Labs/start-os --branch latest | awk '{ print $1}')" >> $GITHUB_ENV - - name: Cache Packages - uses: buildjet/cache@v3 - id: packageCache - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-c-lightning-${{ env.EMBASSYHASH }} - - name: Install Dependencies - run: | - sudo snap install yq deno - sudo apt-get install -y build-essential openssl libssl-dev libc6-dev clang libclang-dev ca-certificates + - name: Prepare StartOS SDK + uses: Start9Labs/sdk@v1 + - name: Checkout services repository uses: actions/checkout@v3 - - name: Install Package Manager - id: packageManager - if: steps.packageCache.outputs.cache-hit != 'true' - run: | - cd ~/ && git clone https://github.com/Start9Labs/start-os.git --branch latest; - cd start-os; - git submodule update --init --recursive - cd backend; - export RUSTFLAGS=""; - export OS_ARCH=$(uname -m); - ./install-sdk.sh; - cargo install --git=https://github.com/Start9Labs/md-packer.git --branch=main; + - name: Build the service package run: | - git submodule u`pdate --init --recursive - embassy-sdk init + git submodule update --init --recursive + start-sdk init make + + - name: Setting package ID and title from the manifest + id: package + run: | + echo "::set-output name=package_id::$(yq -oy ".id" manifest.*)" + echo "::set-output name=package_title::$(yq -oy ".title" manifest.*)" + shell: bash + - name: Generate sha256 checksum run: | - sha256sum c-lightning.s9pk > c-lightning.s9pk.sha256 + PACKAGE_ID=${{ steps.package.outputs.package_id }} + sha256sum ${PACKAGE_ID}.s9pk > ${PACKAGE_ID}.s9pk.sha256 + shell: bash + - name: Generate changelog run: | + PACKAGE_ID=${{ steps.package.outputs.package_id }} echo "## What's Changed" > change-log.txt - yq e '.release-notes' manifest.yaml >> change-log.txt - - name: Create Release + yq -oy '.release-notes' manifest.* >> change-log.txt + echo "## SHA256 Hash" >> change-log.txt + echo '```' >> change-log.txt + sha256sum ${PACKAGE_ID}.s9pk >> change-log.txt + echo '```' >> change-log.txt + shell: bash + + - name: Create GitHub Release uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref_name }} - name: Core Lightning ${{ github.ref_name }} + name: ${{ steps.package.outputs.package_title }} ${{ github.ref_name }} + prerelease: true body_path: change-log.txt files: | - c-lightning.s9pk - c-lightning.s9pk.sha256 + ./${{ steps.package.outputs.package_id }}.s9pk + ./${{ steps.package.outputs.package_id }}.s9pk.sha256 + + - name: Publish to Registry + env: + S9USER: ${{ secrets.S9USER }} + S9PASS: ${{ secrets.S9PASS }} + S9REGISTRY: ${{ secrets.S9REGISTRY }} + run: | + if [[ -z "$S9USER" || -z "$S9PASS" || -z "$S9REGISTRY" ]]; then + echo "Publish skipped: missing registry credentials." + else + start-sdk publish https://$S9USER:$S9PASS@$S9REGISTRY ${{ steps.package.outputs.package_id }}.s9pk + fi