diff --git a/.github/workflows/build_dev_container.yml b/.github/workflows/build_dev_container.yml new file mode 100644 index 0000000..6cea3e7 --- /dev/null +++ b/.github/workflows/build_dev_container.yml @@ -0,0 +1,52 @@ +name: Create Dev Image +on: + push: + branches: ["master"] + +jobs: + build-and-push: + name: Build and Push + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Get Unix Time + id: timestamp + run: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT + + - name: Get SHA + id: sha + run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Get Branch Name + id: branch + run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT + + - name: Set Image Tag + id: itag + run: echo "itag=${{ steps.branch.outputs.branch }}-${{ steps.sha.outputs.sha }}-${{ steps.timestamp.outputs.timestamp }}" >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v6 + env: + IMAGE_TAG: ${{ steps.itag.outputs.itag }} + with: + platforms: linux/amd64, linux/arm64, linux/arm + push: true + tags: | + firstbatch/dkn-compute-node:unstable + firstbatch/dkn-compute-node:${{ env.IMAGE_TAG }} diff --git a/.github/workflows/build_prod_container.yml b/.github/workflows/build_prod_container.yml new file mode 100644 index 0000000..2aa4845 --- /dev/null +++ b/.github/workflows/build_prod_container.yml @@ -0,0 +1,68 @@ +name: Create Prod Image +on: + release: + types: [published] + +jobs: + check-release: + name: Check Release + runs-on: ubuntu-latest + outputs: + image_tag: ${{ steps.set_tag.outputs.itag }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set Image Tag + id: itag + run: echo "itag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT + + - name: Check Release Tag + run: | + if [[ ! "${{ steps.itag.outputs.itag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Release tag format is invalid. It should follow the pattern 'vMAJOR.MINOR.PATCH' (e.g., v1.0.0)." + exit 1 + fi + echo "Release tag format is valid." + + - name: Check Cargo.toml Version + run: | + CARGO_VERSION=$(grep '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/') + TAG_VERSION=${{ steps.itag.outputs.itag }} + TAG_VERSION=${TAG_VERSION#"v"} # Remove the leading 'v' from the tag + + if [[ "$CARGO_VERSION" != "$TAG_VERSION" ]]; then + echo "Version in Cargo.toml ($CARGO_VERSION) does not match the release tag version ($TAG_VERSION)." + exit 1 + fi + echo "Cargo.toml version matches the release tag." + + build-and-push: + name: Build and Push + needs: check-release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64, linux/arm64, linux/arm + push: true + tags: | + firstbatch/dkn-compute-node:latest + firstbatch/dkn-compute-node:${{ needs.check-release.outputs.image_tag }} diff --git a/Cargo.lock b/Cargo.lock index 1640116..1cbbe29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1111,7 +1111,7 @@ dependencies = [ [[package]] name = "dkn-compute" -version = "0.3.1" +version = "0.1.0" dependencies = [ "async-trait", "base64 0.22.1", diff --git a/Cargo.toml b/Cargo.toml index 5680372..468d482 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dkn-compute" -version = "0.3.1" +version = "0.1.0" edition = "2021" license = "Apache-2.0" readme = "README.md"