|
| 1 | +name: Feature Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write # damit wir den VERSION-Commit pushen können |
| 8 | + |
| 9 | +jobs: |
| 10 | + feature-build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + env: |
| 14 | + GIT_USER_NAME: GitHub Pipeline |
| 15 | + GIT_USER_EMAIL: github_pipeline@fairagro.net |
| 16 | + IMAGE_NAME: zalf/fairagro_advanced_middleware_api |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v5 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Set up GitVersion |
| 25 | + id: gitversion |
| 26 | + uses: gittools/actions/gitversion/execute@v3 |
| 27 | + with: |
| 28 | + versionSpec: 5.x |
| 29 | + updateAssemblyInfo: false |
| 30 | + showVariable: FullSemVer |
| 31 | + |
| 32 | + - name: Show computed feature version |
| 33 | + run: 'echo "Feature Version: ${{ steps.gitversion.outputs.FullSemVer }}"' |
| 34 | + |
| 35 | + - name: Update pyproject.toml with feature version and create tag |
| 36 | + run: | |
| 37 | + VERSION="${{ steps.gitversion.outputs.FullSemVer }}" |
| 38 | + echo "Updating pyproject.toml version to $VERSION" |
| 39 | +
|
| 40 | + # Backup |
| 41 | + cp pyproject.toml pyproject.toml.bak |
| 42 | +
|
| 43 | + sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml |
| 44 | +
|
| 45 | + # Optional commit |
| 46 | + git config user.name "${{ env.GIT_USER_NAME }}" |
| 47 | + git config user.email "{{ env.GIT_USER_EMAIL }}" |
| 48 | + git add pyproject.toml |
| 49 | + git commit -m "Update version to $VERSION" || echo "No changes to commit" |
| 50 | + git tag -a "v${VERSION}" -m "Release $VERSION" |
| 51 | + git push origin HEAD:${GITHUB_REF#refs/heads/} |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + |
| 55 | + - name: Set up Docker Buildx |
| 56 | + uses: docker/setup-buildx-action@v3 |
| 57 | + |
| 58 | + - name: Docker metadata |
| 59 | + id: metadata |
| 60 | + uses: docker/metadata-action@v5 |
| 61 | + with: |
| 62 | + images: ${{ env.IMAGE_NAME }} |
| 63 | + tags: ${{ steps.gitversion.outputs.FullSemVer }} |
| 64 | + |
| 65 | + # TODO: implement container structure tests |
| 66 | + # - name: Build and export to Docker |
| 67 | + # uses: docker/build-push-action@v6 |
| 68 | + # with: |
| 69 | + # load: true |
| 70 | + # tags: middleware:test |
| 71 | + # labels: ${{ steps.metadata.outputs.labels }} # we need the labels as they're checked for |
| 72 | + |
| 73 | + # - name: Test image |
| 74 | + # uses: plexsystems/container-structure-test-action@v0.3.0 |
| 75 | + # with: |
| 76 | + # image: middleware:test |
| 77 | + # config: test/container-structure-test/container-structure-test-config.yml |
| 78 | + |
| 79 | + # Secrets are managed within the github GUI |
| 80 | + - name: Log in to Docker Hub |
| 81 | + uses: docker/login-action@v3 |
| 82 | + with: |
| 83 | + username: ${{ secrets.DOCKERHUB_USER }} |
| 84 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 85 | + |
| 86 | + - name: Build & Push Docker Image |
| 87 | + uses: docker/build-push-action@v6 |
| 88 | + with: |
| 89 | + push: true |
| 90 | + tags: ${{ steps.metadata.outputs.tags }} |
| 91 | + labels: ${{ steps.metadata.outputs.labels }} |
| 92 | + |
0 commit comments