diff --git a/.github/workflows/Dev-Container-Publish.yaml b/.github/workflows/Dev-Container-Publish.yaml new file mode 100644 index 0000000..d8d3a80 --- /dev/null +++ b/.github/workflows/Dev-Container-Publish.yaml @@ -0,0 +1,51 @@ +name: Dev Container Publish + +on: + workflow_dispatch: + +jobs: + prepare: + runs-on: ubuntu-latest + outputs: + short_sha: ${{ steps.vars.outputs.short_sha }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get short SHA + id: vars + run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + docker-publish-dashboard: + needs: prepare + uses: ./.github/workflows/reusable-docker-publish.yml + permissions: + contents: write + packages: write + attestations: write + id-token: write + with: + image_name: ${{ github.repository }}/dashboard + dockerfile: ./Containerfile.dashboard + tags: | + ghcr.io/${{ github.repository }}/dashboard:dev + ghcr.io/${{ github.repository }}/dashboard:dev-${{ needs.prepare.outputs.short_sha }} + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + + docker-publish-python: + needs: prepare + uses: ./.github/workflows/reusable-docker-publish.yml + permissions: + contents: write + packages: write + attestations: write + id-token: write + with: + image_name: ${{ github.repository }}/python + dockerfile: ./Containerfile.python + tags: | + ghcr.io/${{ github.repository }}/python:dev + ghcr.io/${{ github.repository }}/python:dev-${{ needs.prepare.outputs.short_sha }} + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/Sync-dev-with-main.yml b/.github/workflows/Sync-dev-with-main.yml new file mode 100644 index 0000000..5d43232 --- /dev/null +++ b/.github/workflows/Sync-dev-with-main.yml @@ -0,0 +1,47 @@ +name: Rebase main and dev and add .dev to version + +on: + workflow_run: + workflows: ["Tag and Release"] + types: + - completed + workflow_dispatch: + +jobs: + rebase: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + token: ${{ secrets.BOT_ACCESS_TOKEN }} + + - name: Setup Git + run: | + git config user.email "github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + + - name: Fetch all branches + run: git fetch --all + + - name: Rebase dev with main + run: | + git checkout dev + git rebase origin/main + + - name: Update the version to .dev + id: update_version + run: | + version_number=$(cat VERSION) + if [[ "$version_number" != *.dev ]]; then + echo "${version_number}.dev" > VERSION + fi + + - name: Commit changes + run: | + git add VERSION + git commit -m "Dev Version update" + git push --force-with-lease diff --git a/.github/workflows/Tag-and-Release.yml b/.github/workflows/Tag-and-Release.yml new file mode 100644 index 0000000..af43aef --- /dev/null +++ b/.github/workflows/Tag-and-Release.yml @@ -0,0 +1,101 @@ +name: Tag and Release + +on: + pull_request: + types: [closed] + branches: ['main'] + +jobs: + release: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get_tag.outputs.version }} + permissions: + contents: write + packages: write + attestations: write + id-token: write + if: startsWith(github.event.pull_request.title, 'Release:') && github.event.pull_request.merged == true + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Git + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + - name: Get tag + id: get_tag + run: | + git pull + echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT + + - name: Tag the commit + run: | + next_version=${{ steps.get_tag.outputs.version }} + git tag -a "$next_version" -m "Version $next_version" + git push --follow-tags + + docker-publish-dashboard: + needs: release + uses: ./.github/workflows/reusable-docker-publish.yml + permissions: + contents: write + packages: write + attestations: write + id-token: write + with: + image_name: ${{ github.repository }}/dashboard + dockerfile: ./Containerfile.dashboard + tags: | + ghcr.io/${{ github.repository }}/dashboard:${{ needs.release.outputs.version }} + ghcr.io/${{ github.repository }}/dashboard:latest + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + + docker-publish-python: + needs: release + uses: ./.github/workflows/reusable-docker-publish.yml + permissions: + contents: write + packages: write + attestations: write + id-token: write + with: + image_name: ${{ github.repository }}/python + dockerfile: ./Containerfile.python + tags: | + ghcr.io/${{ github.repository }}/python:${{ needs.release.outputs.version }} + ghcr.io/${{ github.repository }}/python:latest + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + + create-release: + needs: [release, docker-publish-dashboard, docker-publish-python] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Create changelog diff + run: | + sed -n '/#### \[${{ needs.release.outputs.version }}\]/,/^#### /p' CHANGELOG.md | sed '$d' > release_notes.md + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.release.outputs.version }} + name: Release ${{ needs.release.outputs.version }} + body_path: ./release_notes.md + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Delete release_notes file + run: rm release_notes.md diff --git a/.github/workflows/Update-Version-and-create-Releases-PR.yml b/.github/workflows/Update-Version-and-create-Releases-PR.yml new file mode 100644 index 0000000..e28a0ad --- /dev/null +++ b/.github/workflows/Update-Version-and-create-Releases-PR.yml @@ -0,0 +1,58 @@ +name: Update version and create Release's PR + +on: + workflow_dispatch: + inputs: + version: + description: 'Version name' + required: true + type: string + pattern: '^[0-9]+\.[0-9]+\.[0-9]+$' + +jobs: + version: + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: main + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Setup Git + run: | + git config user.email "github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + - name: Update the version + id: update_version + run: | + echo '${{ inputs.version }}' > VERSION + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + - name: Update Changelog + run: | + npm install -g auto-changelog + auto-changelog -v ${{ steps.update_version.outputs.version }} + - name: Create pull request + id: create_pr + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: release/${{ steps.update_version.outputs.version }} + title: "Release: Candidate Version ${{ steps.update_version.outputs.version }} Pull Request" + body: "This pull request contains the updated VERSION file with the new release version and an updated CHANGELOG.md file." + base: main + assignees: paulstretenowich + reviewers: paulstretenowich + delete-branch: true + labels: automated pr diff --git a/.github/workflows/reusable-docker-publish.yml b/.github/workflows/reusable-docker-publish.yml new file mode 100644 index 0000000..7896e0a --- /dev/null +++ b/.github/workflows/reusable-docker-publish.yml @@ -0,0 +1,66 @@ +name: Docker Publish + +on: + workflow_call: + inputs: + image_name: + required: true + type: string + tags: + required: true + type: string + platforms: + required: false + type: string + default: linux/amd64,linux/arm64 + dockerfile: + required: false + type: string + default: ./Containerfile + context: + required: false + type: string + default: . + secrets: + token: + required: true + +jobs: + docker-publish: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Update package lists + run: sudo apt-get update + + - name: Install QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.token }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: ${{ inputs.context }} + file: ${{ inputs.dockerfile }} + push: true + sbom: true + provenance: true + tags: ${{ inputs.tags }} + platforms: ${{ inputs.platforms }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..bd48566 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +### Changelog + +All notable changes to this project will be documented in this file. Dates are displayed in UTC. + +Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..8acdd82 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.1