|
| 1 | +name: Development Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - develop |
| 7 | + tags-ignore: |
| 8 | + - '*' |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + discussions: write |
| 13 | + packages: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + cleanup-old-releases: |
| 17 | + name: Cleanup Old Development Releases |
| 18 | + runs-on: ubuntu-22.04 |
| 19 | + steps: |
| 20 | + - name: Delete old development releases |
| 21 | + uses: dev-drprasad/delete-older-releases@v0.3.2 |
| 22 | + with: |
| 23 | + keep_latest: 5 |
| 24 | + delete_tags: true |
| 25 | + delete_tag_pattern: ^dev- |
| 26 | + env: |
| 27 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + |
| 29 | + build-and-release: |
| 30 | + name: Build and Create Development Release |
| 31 | + needs: cleanup-old-releases |
| 32 | + # Using a larger runner with more CPU cores and memory |
| 33 | + runs-on: xl-runner |
| 34 | + |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v3 |
| 37 | + with: |
| 38 | + fetch-depth: 0 |
| 39 | + |
| 40 | + - name: Install Rust toolchain |
| 41 | + uses: actions-rs/toolchain@v1 |
| 42 | + with: |
| 43 | + toolchain: stable |
| 44 | + override: true |
| 45 | + |
| 46 | + # Use all available cores for the build |
| 47 | + - name: Build all workspace members |
| 48 | + run: | |
| 49 | + export CARGO_BUILD_JOBS=$(nproc) |
| 50 | + cargo build --release --workspace |
| 51 | +
|
| 52 | + - name: Prepare binaries |
| 53 | + run: | |
| 54 | + mkdir -p release-artifacts |
| 55 | + if [ -f target/release/miner ]; then |
| 56 | + cp target/release/miner release-artifacts/miner-linux-x86_64 |
| 57 | + fi |
| 58 | + if [ -f target/release/validator ]; then |
| 59 | + cp target/release/validator release-artifacts/validator-linux-x86_64 |
| 60 | + fi |
| 61 | + if [ -f target/release/orchestrator ]; then |
| 62 | + cp target/release/orchestrator release-artifacts/orchestrator-linux-x86_64 |
| 63 | + fi |
| 64 | + if [ -f target/release/discovery ]; then # Prepare discovery binary |
| 65 | + cp target/release/discovery release-artifacts/discovery-linux-x86_64 |
| 66 | + fi |
| 67 | +
|
| 68 | + - name: Generate checksums |
| 69 | + run: | |
| 70 | + cd release-artifacts |
| 71 | + for file in *-linux-x86_64; do |
| 72 | + if [ -f "$file" ]; then |
| 73 | + sha256sum "$file" | cut -d ' ' -f 1 > "${file}.checksum" |
| 74 | + fi |
| 75 | + done |
| 76 | + cd .. |
| 77 | +
|
| 78 | + - name: Generate release tag |
| 79 | + id: tag |
| 80 | + run: | |
| 81 | + echo "tag_name=dev-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
| 82 | +
|
| 83 | + - name: Create Release |
| 84 | + uses: softprops/action-gh-release@v1 |
| 85 | + with: |
| 86 | + tag_name: ${{ steps.tag.outputs.tag_name }} |
| 87 | + name: Development Build ${{ steps.tag.outputs.tag_name }} |
| 88 | + body: | |
| 89 | + ⚠️ Development Build (Not for Production Use) |
| 90 | + |
| 91 | + Branch: develop |
| 92 | + Commit: ${{ github.sha }} |
| 93 | + Build Date: ${{ steps.tag.outputs.tag_name }} |
| 94 | + |
| 95 | + Platform: |
| 96 | + - Linux x86_64 |
| 97 | + |
| 98 | + Components: |
| 99 | + - Miner |
| 100 | + - Validator |
| 101 | + - Orchestrator |
| 102 | + - Discovery svc |
| 103 | + |
| 104 | + Note: This is an automated development build. For stable releases, please use builds from the master branch. |
| 105 | + files: release-artifacts/* |
| 106 | + prerelease: true |
| 107 | + generate_release_notes: true |
| 108 | + env: |
| 109 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + |
| 111 | + - name: Authenticate to Google Cloud |
| 112 | + uses: google-github-actions/auth@v1 |
| 113 | + with: |
| 114 | + credentials_json: ${{ secrets.GCP_SA_KEY }} |
| 115 | + |
| 116 | + # Setup Google Cloud SDK |
| 117 | + - name: Set up Google Cloud SDK |
| 118 | + uses: google-github-actions/setup-gcloud@v1 |
| 119 | + |
| 120 | + # Upload to Google Cloud Storage |
| 121 | + - name: Upload to GCS |
| 122 | + run: | |
| 123 | + gsutil -m cp -r release-artifacts/* gs://prime-miner/${{ steps.tag.outputs.tag_name }}/ |
| 124 | + gsutil -m cp -r gs://prime-miner/${{ steps.tag.outputs.tag_name }}/* gs://prime-miner/latest/ |
| 125 | + gsutil -m setmeta -h "Cache-Control:no-cache, max-age=0" gs://prime-miner/latest/**/* |
| 126 | +
|
| 127 | + - name: Generate Docker metadata |
| 128 | + id: meta |
| 129 | + run: | |
| 130 | + REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') |
| 131 | + echo "repo_lower=${REPO_LOWER}" >> $GITHUB_OUTPUT |
| 132 | +
|
| 133 | + - name: Configure Docker for Artifact Registry |
| 134 | + run: | |
| 135 | + gcloud auth configure-docker us-east1-docker.pkg.dev |
| 136 | +
|
| 137 | + - name: Set up Docker Buildx |
| 138 | + uses: docker/setup-buildx-action@v2 |
| 139 | + |
| 140 | + - name: Login to GitHub Container Registry |
| 141 | + uses: docker/login-action@v2 |
| 142 | + with: |
| 143 | + registry: ghcr.io |
| 144 | + username: ${{ github.actor }} |
| 145 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 146 | + |
| 147 | + - name: Build and push Discovery image |
| 148 | + uses: docker/build-push-action@v4 |
| 149 | + with: |
| 150 | + context: . |
| 151 | + file: ./discovery/Dockerfile |
| 152 | + push: true |
| 153 | + tags: | |
| 154 | + ghcr.io/${{ steps.meta.outputs.repo_lower }}/discovery:dev |
| 155 | + ghcr.io/${{ steps.meta.outputs.repo_lower }}/discovery:${{ steps.tag.outputs.tag_name }} |
| 156 | + us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/discovery:dev |
| 157 | + us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/discovery:${{ steps.tag.outputs.tag_name }} |
| 158 | +
|
| 159 | + - name: Build and push Validator image |
| 160 | + uses: docker/build-push-action@v4 |
| 161 | + with: |
| 162 | + context: . |
| 163 | + file: ./validator/Dockerfile |
| 164 | + push: true |
| 165 | + tags: | |
| 166 | + ghcr.io/${{ steps.meta.outputs.repo_lower }}/validator:dev |
| 167 | + ghcr.io/${{ steps.meta.outputs.repo_lower }}/validator:${{ steps.tag.outputs.tag_name }} |
| 168 | + us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/validator:dev |
| 169 | + us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/validator:${{ steps.tag.outputs.tag_name }} |
| 170 | +
|
| 171 | + - name: Build and push Orchestrator image |
| 172 | + uses: docker/build-push-action@v4 |
| 173 | + with: |
| 174 | + context: . |
| 175 | + file: ./orchestrator/Dockerfile |
| 176 | + push: true |
| 177 | + tags: | |
| 178 | + ghcr.io/${{ steps.meta.outputs.repo_lower }}/orchestrator:dev |
| 179 | + ghcr.io/${{ steps.meta.outputs.repo_lower }}/orchestrator:${{ steps.tag.outputs.tag_name }} |
| 180 | + us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/orchestrator:dev |
| 181 | + us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/prime-miner/orchestrator:${{ steps.tag.outputs.tag_name }} |
0 commit comments