|
| 1 | +# Workflow that publishes a new TACO version once a matching tag is created |
| 2 | +name: Publish to crates.io, Create Release Draft & Build Container Image |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + push: |
| 7 | + tags: |
| 8 | + - "v*.*.*" |
| 9 | + - "v*.*.*-alpha.*" |
| 10 | + - "v*.*.*-beta.*" |
| 11 | + - "v*.*.*-rc.*" |
| 12 | + |
| 13 | +env: |
| 14 | + CARGO_TERM_COLOR: always |
| 15 | + MIN_RUST_VERSION: "1.92.0" |
| 16 | + REGISTRY: ghcr.io |
| 17 | + IMAGE_NAME: "${{ github.repository }}" |
| 18 | + |
| 19 | +jobs: |
| 20 | + # Validate minimum supported Rust version declared in `Cargo.toml`. |
| 21 | + # Note that warnings are allowed as some may appear due to backwards |
| 22 | + # compatiblity issues. |
| 23 | + minimum-supported: |
| 24 | + name: Minimum version |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + - name: Install rust version |
| 29 | + run: rustup install ${MIN_RUST_VERSION} |
| 30 | + - name: Install Dependencies (Z3,CVC5,Graphviz) |
| 31 | + run: sudo apt-get install -y z3 cvc5 graphviz |
| 32 | + - name: check |
| 33 | + run: cargo +${MIN_RUST_VERSION} check --all-features |
| 34 | + - name: check |
| 35 | + run: cargo +${MIN_RUST_VERSION} test --all-features |
| 36 | + |
| 37 | + # Publish the new version to crates.io |
| 38 | + crates_io_publish: |
| 39 | + name: Publish (Crates.io) & Create Release Draft |
| 40 | + needs: minimum-supported |
| 41 | + environment: release |
| 42 | + runs-on: ubuntu-latest |
| 43 | + permissions: |
| 44 | + id-token: write # Required for OIDC token exchange |
| 45 | + contents: write # required to create a release |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + - name: Install rust version |
| 49 | + run: rustup install ${MIN_RUST_VERSION} |
| 50 | + - uses: rust-lang/crates-io-auth-action@v1 |
| 51 | + id: auth |
| 52 | + - run: cargo publish --workspace |
| 53 | + env: |
| 54 | + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |
| 55 | + - name: Create draft release |
| 56 | + uses: softprops/action-gh-release@v2 |
| 57 | + with: |
| 58 | + tag_name: ${{ steps.version.outputs.tag }} |
| 59 | + draft: true |
| 60 | + body: "This is a release draft generated by Github Actions..." |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + |
| 64 | + # Build the TACO container for the release |
| 65 | + build_container: |
| 66 | + name: Build Container Image |
| 67 | + environment: release |
| 68 | + needs: minimum-supported |
| 69 | + runs-on: ubuntu-latest |
| 70 | + permissions: |
| 71 | + contents: read |
| 72 | + packages: write |
| 73 | + attestations: write |
| 74 | + id-token: write |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + - name: Login to GitHub Container Registry |
| 78 | + uses: docker/login-action@v3 |
| 79 | + with: |
| 80 | + registry: ${{ env.REGISTRY }} |
| 81 | + username: ${{ github.actor }} |
| 82 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + - name: Extract metadata (tags, labels) for Docker |
| 84 | + id: meta |
| 85 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 86 | + with: |
| 87 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 88 | + tags: | |
| 89 | + type=semver,pattern={{version}} |
| 90 | + type=semver,pattern={{major}}.{{minor}} |
| 91 | + type=raw,value=latest |
| 92 | + - name: Set up QEMU |
| 93 | + uses: docker/setup-qemu-action@v3 |
| 94 | + - name: Set up Docker Buildx |
| 95 | + uses: docker/setup-buildx-action@v3 |
| 96 | + - name: Build and push |
| 97 | + uses: docker/build-push-action@v6 |
| 98 | + id: push |
| 99 | + with: |
| 100 | + platforms: linux/amd64 # ,linux/arm64 (currently fails for CUDD) |
| 101 | + context: . |
| 102 | + push: true |
| 103 | + tags: ${{ steps.meta.outputs.tags }} |
| 104 | + labels: ${{ steps.meta.outputs.labels }} |
| 105 | + - name: Generate artifact attestation |
| 106 | + uses: actions/attest-build-provenance@v3 |
| 107 | + with: |
| 108 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} |
| 109 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 110 | + push-to-registry: true |
0 commit comments