fix: publish hm-dsl-engine to crates.io (harmont-cli dep) #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| crates-io: | |
| name: Publish to crates.io | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Install esbuild (for harmont-ts bundle) | |
| working-directory: dsls/harmont-ts | |
| run: npm ci | |
| - name: Set version from tag | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
| # Bump crate versions | |
| sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm-util/Cargo.toml | |
| sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm-pipeline-ir/Cargo.toml | |
| sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm-plugin-protocol/Cargo.toml | |
| sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm-plugin-cloud/Cargo.toml | |
| sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm-dsl-engine/Cargo.toml | |
| sed -i "0,/version = \"0.0.0-dev\"/s//version = \"$VERSION\"/" crates/hm/Cargo.toml | |
| # Rewrite workspace.dependencies pins so dependents resolve to the | |
| # tagged version (cargo publish strips path deps; the version field | |
| # is what consumers will receive). | |
| sed -i "s|hm-util = { path = \"crates/hm-util\", version = \"0.0.0-dev\" }|hm-util = { path = \"crates/hm-util\", version = \"$VERSION\" }|" Cargo.toml | |
| sed -i "s|hm-pipeline-ir = { path = \"crates/hm-pipeline-ir\", version = \"0.0.0-dev\" }|hm-pipeline-ir = { path = \"crates/hm-pipeline-ir\", version = \"$VERSION\" }|" Cargo.toml | |
| sed -i "s|hm-plugin-protocol = { path = \"crates/hm-plugin-protocol\", version = \"0.0.0-dev\" }|hm-plugin-protocol = { path = \"crates/hm-plugin-protocol\", version = \"$VERSION\" }|" Cargo.toml | |
| sed -i "s|hm-plugin-cloud = { path = \"crates/hm-plugin-cloud\", version = \"0.0.0-dev\" }|hm-plugin-cloud = { path = \"crates/hm-plugin-cloud\", version = \"$VERSION\" }|" Cargo.toml | |
| sed -i "s|hm-dsl-engine = { path = \"crates/hm-dsl-engine\", version = \"0.0.0-dev\" }|hm-dsl-engine = { path = \"crates/hm-dsl-engine\", version = \"$VERSION\" }|" Cargo.toml | |
| cargo check --workspace --exclude hm-fixtures | |
| - name: Publish hm-util | |
| run: | | |
| if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/hm-util/$VERSION" > /dev/null 2>&1; then | |
| echo "hm-util@$VERSION already published, skipping" | |
| else | |
| cargo publish -p hm-util --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty | |
| fi | |
| - name: Wait for crates.io index | |
| run: sleep 30 | |
| - name: Publish hm-pipeline-ir | |
| run: | | |
| if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/hm-pipeline-ir/$VERSION" > /dev/null 2>&1; then | |
| echo "hm-pipeline-ir@$VERSION already published, skipping" | |
| else | |
| cargo publish -p hm-pipeline-ir --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty | |
| fi | |
| - name: Wait for crates.io index | |
| run: sleep 30 | |
| - name: Publish hm-plugin-protocol | |
| run: | | |
| if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/hm-plugin-protocol/$VERSION" > /dev/null 2>&1; then | |
| echo "hm-plugin-protocol@$VERSION already published, skipping" | |
| else | |
| cargo publish -p hm-plugin-protocol --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty | |
| fi | |
| - name: Wait for crates.io index | |
| run: sleep 30 | |
| - name: Publish hm-plugin-cloud | |
| run: | | |
| if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/hm-plugin-cloud/$VERSION" > /dev/null 2>&1; then | |
| echo "hm-plugin-cloud@$VERSION already published, skipping" | |
| else | |
| cargo publish -p hm-plugin-cloud --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty | |
| fi | |
| - name: Wait for crates.io index | |
| run: sleep 30 | |
| - name: Publish hm-dsl-engine | |
| run: | | |
| if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/hm-dsl-engine/$VERSION" > /dev/null 2>&1; then | |
| echo "hm-dsl-engine@$VERSION already published, skipping" | |
| else | |
| cargo publish -p hm-dsl-engine --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty | |
| fi | |
| - name: Wait for crates.io index | |
| run: sleep 30 | |
| - name: Publish harmont-cli | |
| run: | | |
| if curl -sf -A "harmont-release-ci (github-actions)" "https://crates.io/api/v1/crates/harmont-cli/$VERSION" > /dev/null 2>&1; then | |
| echo "harmont-cli@$VERSION already published, skipping" | |
| else | |
| cargo publish -p harmont-cli --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty | |
| fi | |
| build-binary: | |
| name: Build ${{ matrix.target }} | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| - target: aarch64-unknown-linux-gnu | |
| runner: ubuntu-24.04-arm | |
| - target: aarch64-apple-darwin | |
| runner: macos-latest | |
| - target: x86_64-apple-darwin | |
| runner: macos-latest | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: npm | |
| cache-dependency-path: dsls/harmont-ts/package-lock.json | |
| - name: Install esbuild | |
| working-directory: dsls/harmont-ts | |
| run: npm ci | |
| - name: Set version from tag | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
| sed -i'' -e 's/version = "0.0.0-dev"/version = "'"$VERSION"'"/' crates/hm/Cargo.toml | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} -p harmont-cli | |
| - name: Package | |
| run: | | |
| ARCHIVE="hm-${{ matrix.target }}.tar.gz" | |
| tar czf "$ARCHIVE" -C "target/${{ matrix.target }}/release" hm | |
| sha256sum "$ARCHIVE" > "$ARCHIVE.sha256" || shasum -a 256 "$ARCHIVE" > "$ARCHIVE.sha256" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: hm-${{ matrix.target }} | |
| path: | | |
| hm-${{ matrix.target }}.tar.gz | |
| hm-${{ matrix.target }}.tar.gz.sha256 | |
| retention-days: 1 | |
| github-release: | |
| name: Create GitHub Release | |
| timeout-minutes: 10 | |
| needs: build-binary | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Create or update release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then | |
| gh release upload "$GITHUB_REF_NAME" \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --clobber \ | |
| artifacts/* | |
| else | |
| gh release create "$GITHUB_REF_NAME" \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --title "$GITHUB_REF_NAME" \ | |
| --generate-notes \ | |
| artifacts/* | |
| fi |