Fix links in README for api ref #79
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: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| version_override: | |
| description: "Manually specify the release version (e.g. 1.2.3)" | |
| required: false | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| jobs: | |
| create-tag: | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event_name == 'pull_request' && | |
| github.event.pull_request.merged == true && | |
| (contains(github.event.pull_request.labels.*.name, 'beta') || | |
| contains(github.event.pull_request.labels.*.name, 'rc') || | |
| contains(github.event.pull_request.labels.*.name, 'release') || | |
| contains(github.event.pull_request.labels.*.name, 'patch') || | |
| contains(github.event.pull_request.labels.*.name, 'minor') || | |
| contains(github.event.pull_request.labels.*.name, 'major'))) | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.versioning.outputs.VERSION }} | |
| prerelease: ${{ steps.versioning.outputs.PRERELEASE }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Set up Git | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| - name: Determine version | |
| id: versioning | |
| run: | | |
| # 1) If manual workflow_dispatch override given, use that | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]] && \ | |
| [[ -n "${{ github.event.inputs.version_override }}" ]]; then | |
| VERSION="${{ github.event.inputs.version_override }}" | |
| PRE="false" | |
| echo "Using manual override: $VERSION" | |
| else | |
| # 2) Extract version from pyproject.toml or Cargo.toml | |
| if [ -f "pyproject.toml" ]; then | |
| VERSION=$(grep '^version = "' pyproject.toml | cut -d'"' -f2) | |
| elif [ -f "ptolemy-py/Cargo.toml" ]; then | |
| VERSION=$(grep '^version = "' ptolemy-py/Cargo.toml | head -1 | cut -d'"' -f2 | sed 's/+.*//') | |
| else | |
| echo "Could not find version file." | |
| exit 1 | |
| fi | |
| # 3) Determine prerelease type | |
| if [[ "${{ contains(github.event.pull_request.labels.*.name, 'beta') }}" == "true" ]]; then | |
| PRE="true" | |
| elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'rc') }}" == "true" ]]; then | |
| PRE="true" | |
| else | |
| PRE="false" | |
| fi | |
| fi | |
| echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "PRERELEASE=${PRE}" >> $GITHUB_OUTPUT | |
| - name: Create tag if missing | |
| run: | | |
| VERSION="${{ steps.versioning.outputs.VERSION }}" | |
| if git rev-parse "v${VERSION}" >/dev/null 2>&1; then | |
| echo "Tag v${VERSION} already exists." | |
| else | |
| git tag -a "v${VERSION}" -m "Version ${VERSION}" | |
| git push origin "v${VERSION}" | |
| fi | |
| publish-encoderfile: | |
| needs: create-tag | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Project setup | |
| uses: ./.github/actions/project-setup | |
| - name: Cargo publish (dry-run) | |
| run: cargo publish --dry-run | |
| env: | |
| ENCODERFILE_DEV: "false" | |
| - name: Cargo publish | |
| run: cargo publish | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| ENCODERFILE_DEV: "false" | |
| upload-install-script: | |
| needs: create-tag | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: install | |
| path: install.sh | |
| build-encoderfile: | |
| needs: create-tag | |
| runs-on: ${{ matrix.platform.runner }} | |
| strategy: | |
| matrix: | |
| platform: | |
| - runner: macos-14 | |
| target: x86_64-apple-darwin | |
| - runner: macos-14 | |
| target: aarch64-apple-darwin | |
| - runner: ubuntu-24.04 | |
| target: x86_64-unknown-linux-gnu | |
| - runner: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Project setup | |
| uses: ./.github/actions/project-setup | |
| - name: Install target | |
| run: rustup target add ${{ matrix.platform.target }} | |
| - name: Build | |
| run: cargo build --bin encoderfile --release --target ${{ matrix.platform.target }} | |
| env: | |
| ENCODERFILE_DEV: "false" | |
| - name: Create release tarball | |
| run: | | |
| VERSION="${{ needs.create-tag.outputs.version }}" | |
| TARGET="${{ matrix.platform.target }}" | |
| mkdir -p dist | |
| cp target/${TARGET}/release/encoderfile dist/encoderfile | |
| cp README.md dist/README.md | |
| cp LICENSE dist/LICENSE | |
| test -f THIRDPARTY.md && cp THIRDPARTY.md dist/THIRDPARTY.md | |
| TAR="encoderfile-${TARGET}.tar.gz" | |
| tar -czf "$TAR" -C dist . | |
| echo "Created $TAR" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: encoderfile-${{ matrix.platform.target }} | |
| path: encoderfile-${{ matrix.platform.target }}.tar.gz | |
| create-release: | |
| needs: [create-tag, build-encoderfile, publish-encoderfile, upload-install-script] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.create-tag.outputs.version }} | |
| name: v${{ needs.create-tag.outputs.version }} | |
| prerelease: ${{ needs.create-tag.outputs.prerelease }} | |
| files: | | |
| dist/**/*.tar.gz | |
| dist/install/install.sh | |
| generate_release_notes: true | |
| docker-build: | |
| needs: [create-release, create-tag] | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| platform: linux/amd64 | |
| runner: ubuntu-latest | |
| - arch: arm64 | |
| platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Build image | |
| run: | | |
| docker build \ | |
| --platform ${{ matrix.platform }} \ | |
| -t ghcr.io/${{ github.repository_owner }}/encoderfile:${{ matrix.arch }}-${{ needs.create-tag.outputs.version }} \ | |
| . | |
| - name: Push image | |
| run: | | |
| docker push ghcr.io/${{ github.repository_owner }}/encoderfile:${{ matrix.arch }}-${{ needs.create-tag.outputs.version }} | |
| docker-manifest: | |
| needs: [docker-build, create-tag] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set up Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Create multi-arch manifest | |
| run: | | |
| VERSION=${{ needs.create-tag.outputs.version }} | |
| PRE=${{ needs.create-tag.outputs.prerelease }} | |
| if [[ "$PRE" == "true" ]]; then | |
| echo "Prerelease detected — skipping latest tag" | |
| docker buildx imagetools create \ | |
| -t ghcr.io/${{ github.repository_owner }}/encoderfile:${VERSION} \ | |
| ghcr.io/${{ github.repository_owner }}/encoderfile:amd64-${VERSION} \ | |
| ghcr.io/${{ github.repository_owner }}/encoderfile:arm64-${VERSION} | |
| else | |
| echo "Stable release — tagging latest" | |
| docker buildx imagetools create \ | |
| -t ghcr.io/${{ github.repository_owner }}/encoderfile:${VERSION} \ | |
| -t ghcr.io/${{ github.repository_owner }}/encoderfile:latest \ | |
| ghcr.io/${{ github.repository_owner }}/encoderfile:amd64-${VERSION} \ | |
| ghcr.io/${{ github.repository_owner }}/encoderfile:arm64-${VERSION} | |
| fi |