diff --git a/.github/scripts/build-sizer.sh b/.github/scripts/build-sizer.sh index 15dc08d..aac5905 100755 --- a/.github/scripts/build-sizer.sh +++ b/.github/scripts/build-sizer.sh @@ -34,7 +34,7 @@ cmake -S . -B build \ -DABC_SKIP_TESTS=ON \ -DBUILD_PYTHON=OFF \ -DUSE_SYSTEM_OPENSTA=OFF \ - -DOPENROAD_VERSION=v0.1.0-alpha \ + -DOPENROAD_VERSION="v${SIZER_VERSION:-0.1.0-alpha}" \ -DENABLE_PROFILER="${ENABLE_PROFILER:-OFF}" \ -DCUDD_DIR="${cudd_dir}" \ -DZLIB_HOME=/usr/lib/x86_64-linux-gnu \ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1c5cd6e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,60 @@ +name: Build + +on: + workflow_call: + inputs: + version: + description: >- + Bare semantic version (e.g. 0.1.0-alpha) embedded into the binary + and the package name. Empty keeps the default unversioned package. + type: string + default: '' + outputs: + archive-name: + description: File name of the packaged tarball inside the artifact. + value: ${{ jobs.build-linux-x64.outputs.archive-name }} + +jobs: + build-linux-x64: + name: Build Linux x64 + runs-on: ubuntu-22.04 + outputs: + archive-name: ${{ steps.package.outputs.archive-name }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup sccache + uses: mozilla-actions/sccache-action@v0.0.10 + + - name: Install build dependencies + run: bash .github/scripts/install-build-deps.sh + + - name: Build Sizer + run: .github/scripts/build-sizer.sh + env: + SIZER_VERSION: ${{ inputs.version }} + + - name: Package Sizer with runtime wrapper + id: package + env: + VERSION: ${{ inputs.version }} + run: | + package_name="ecc-sizer" + archive_name="ecc-sizer-linux-x64.tar.gz" + if [[ -n "${VERSION}" ]]; then + package_name="ecc-sizer-${VERSION}" + archive_name="${package_name}-linux-x64.tar.gz" + fi + PACKAGE_NAME="${package_name}" ARCHIVE_NAME="${archive_name}" \ + .github/scripts/package-sizer.sh + echo "archive-name=${archive_name}" >> "${GITHUB_OUTPUT}" + + - name: Upload binary package + uses: actions/upload-artifact@v4 + with: + name: ecc-sizer-linux-x64 + path: dist/*.tar.gz + if-no-files-found: error diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb09d59..479ece1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,25 +15,4 @@ concurrency: jobs: build-linux-x64: name: Build Linux x64 - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Install build dependencies - run: bash .github/scripts/install-build-deps.sh - - - name: Build Sizer - run: .github/scripts/build-sizer.sh - - - name: Package Sizer with runtime wrapper - run: .github/scripts/package-sizer.sh - - - name: Upload binary package - uses: actions/upload-artifact@v4 - with: - name: ecc-sizer-linux-x64 - path: dist/ecc-sizer-linux-x64.tar.gz - if-no-files-found: error + uses: ./.github/workflows/build.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fe877c9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +concurrency: + group: release-${{ github.ref_name }} + cancel-in-progress: false + +jobs: + verify: + name: Verify release tag + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.check.outputs.version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check tag against default.nix version + id: check + run: | + version="${GITHUB_REF_NAME#v}" + nix_version="$(grep -oP 'version = "\K[^"]+' default.nix | head -1)" + echo "tag version: ${version}" + echo "default.nix version: ${nix_version}" + if [[ "${version}" != "${nix_version}" ]]; then + echo "::error::Tag ${GITHUB_REF_NAME} does not match the version \"${nix_version}\" in default.nix. Bump the version and retag." + exit 1 + fi + echo "version=${version}" >> "${GITHUB_OUTPUT}" + + build: + name: Build release package + needs: verify + uses: ./.github/workflows/build.yml + with: + version: ${{ needs.verify.outputs.version }} + + release: + name: Publish GitHub Release + needs: + - verify + - build + runs-on: ubuntu-22.04 + steps: + - name: Download package artifact + uses: actions/download-artifact@v4 + with: + name: ecc-sizer-linux-x64 + + - name: Generate checksums + run: sha256sum -- *.tar.gz > SHA256SUMS.txt + + - name: Publish release + uses: softprops/action-gh-release@v2 + with: + files: | + *.tar.gz + SHA256SUMS.txt + fail_on_unmatched_files: true + generate_release_notes: true + prerelease: ${{ contains(github.ref_name, '-') }} diff --git a/README.md b/README.md index a238a98..84c7f58 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,26 @@ git -C thirdparty/OpenROAD/src/sta status --short --branch git -C thirdparty/OpenROAD/third-party/abc status --short --branch ``` +## Releasing + +Releases are published by pushing a version tag. The Release workflow +verifies the tag, rebuilds the self-contained Linux x64 package, and +publishes a GitHub Release with the tarball and its SHA256 checksums. + +1. Bump the version in `default.nix` and the `SIZER_VERSION` default in + `.github/scripts/build-sizer.sh`, then merge the change to `main`. +2. Tag the release commit and push the tag: + + ```bash + git tag -a v0.1.0-alpha -m "Sizer 0.1.0-alpha" + git push origin v0.1.0-alpha + ``` + +The tag must match the `version` field in `default.nix` (without the +leading `v`), otherwise the workflow fails before building. Tags carrying +a prerelease suffix (for example `-alpha` or `-rc.1`) are published as +prereleases. + ## References - [TritonSizer](https://github.com/The-OpenROAD-Project/TritonSizer)