name: Release on: push: tags: - "v*" permissions: contents: write packages: write jobs: build-linux: name: Build Linux release binary runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 # needed so build.rs can run `git describe` - name: Install Rust stable uses: dtolnay/rust-toolchain@stable with: targets: x86_64-unknown-linux-gnu - name: Cache Cargo registry and build artefacts uses: actions/cache@v4 with: path: | ~/.cargo/registry/index ~/.cargo/registry/cache ~/.cargo/git/db target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo- - name: Build release binary run: cargo build --release --target x86_64-unknown-linux-gnu - name: Rename binary run: | cp target/x86_64-unknown-linux-gnu/release/mikebase \ mikebase-${{ github.ref_name }}-x86_64-linux - name: Create Gitea release and upload binary env: GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITEA_URL: ${{ github.server_url }} REPO: ${{ github.repository }} TAG: ${{ github.ref_name }} run: | # Create the release RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/json" \ "${GITEA_URL}/api/v1/repos/${REPO}/releases" \ -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}") HTTP_CODE=$(echo "$RESPONSE" | tail -1) BODY=$(echo "$RESPONSE" | head -1) if [ "$HTTP_CODE" -ne 201 ]; then echo "Failed to create release (HTTP $HTTP_CODE): $BODY" exit 1 fi RELEASE_ID=$(echo "$BODY" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") # Upload binary asset BINARY="mikebase-${TAG}-x86_64-linux" curl -s -X POST \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/octet-stream" \ "${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${BINARY}" \ --data-binary @"${BINARY}" docker: name: Build and push Docker image runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Log in to Gitea container registry uses: docker/login-action@v3 with: registry: git.open3dlab.com username: ${{ github.actor }} password: ${{ secrets.REGISTRY_TOKEN }} - name: Extract metadata id: meta uses: docker/metadata-action@v5 with: images: git.open3dlab.com/${{ github.repository }} tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=raw,value=latest - name: Build and push uses: docker/build-push-action@v6 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}