From 49af8ec5bc9234586cfd66f45b15494d26d7932c Mon Sep 17 00:00:00 2001 From: emilcode Date: Sun, 24 Aug 2025 13:44:54 +0000 Subject: [PATCH] [changed] build container image in one action and build the lib and the conan package in another action --- .github/workflows/devcontainer.yml | 33 ++++++++++++++++++++++++ .github/workflows/publish-package.yml | 36 +++++++++++++++------------ 2 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/devcontainer.yml diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml new file mode 100644 index 0000000..16b5f0f --- /dev/null +++ b/.github/workflows/devcontainer.yml @@ -0,0 +1,33 @@ +name: Build Devcontainer Image + +on: + push: + paths: + - '.devcontainer/Dockerfile' + - '.devcontainer/**' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write # nötig für Push nach GHCR + + steps: + - uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push devcontainer + uses: docker/build-push-action@v5 + with: + context: . + file: .devcontainer/Dockerfile + push: true + tags: ghcr.io/${{ github.repository_owner }}/embedded-lib-dev:latest \ No newline at end of file diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 1428af5..fa235ff 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -1,34 +1,40 @@ -name: Embedded Lib Conan Package +name: Conan Package on: push: branches: [ main ] - tags: [ "*" ] + tags: [ "v*" ] # Nur Tags, die mit v beginnen (z.B. v1.2.3) pull_request: jobs: build-and-publish: runs-on: ubuntu-latest + container: + image: ghcr.io/${{ github.repository_owner }}/embedded-lib-dev:latest + + permissions: + contents: read + packages: write steps: - # 1. Checkout repo - uses: actions/checkout@v4 - - # 2. Set up Docker Buildx - - name: Build dev container + with: + fetch-depth: 0 # wichtig, damit Tags verfügbar sind + + # Version aus Git-Tag ableiten + - name: Extract version from tag + id: vars run: | - docker build -t my-dev -f .devcontainer/Dockerfile . - docker run my-dev echo "Container built" + TAG=${GITHUB_REF#refs/tags/} + VERSION=${TAG#v} + echo "version=$VERSION" >> $GITHUB_OUTPUT - # 2. Verify environment - name: Check environment run: | - which conan conan --version cmake --version gcc --version - # 3. Configure Conan remote - name: Configure Conan remote run: | conan remote add github "https://conan.pkg.github.com/${{ github.repository_owner }}" --force @@ -37,15 +43,13 @@ jobs: CONAN_LOGIN_USERNAME: ${{ github.actor }} CONAN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - # 4. Create the package - name: Create Conan package run: | - conan create . --version=0.1.0 --user=${{ github.actor }} --channel=stable + conan create . --version=${{ steps.vars.outputs.version }} --user=${{ github.actor }} --channel=stable - # 5. Upload the package - - name: Upload package + - name: Upload Conan package run: | - conan upload "*/0.1.0@" --all -r=github --confirm + conan upload "*/${{ steps.vars.outputs.version }}@" --all -r=github --confirm env: CONAN_LOGIN_USERNAME: ${{ github.actor }} CONAN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}