Update Flox version #9
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: Update Flox version | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' # daily at 06:00 UTC | |
| workflow_dispatch: | |
| jobs: | |
| update-version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Fetch latest version | |
| id: latest | |
| run: | | |
| version=$(curl -sf https://downloads.flox.dev/by-env/stable/LATEST_VERSION | xargs) | |
| [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "unexpected version: '$version'"; exit 1; } | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| - name: Read current version | |
| id: current | |
| run: | | |
| echo "version=$(cat FLOX_VERSION)" >> "$GITHUB_OUTPUT" | |
| - name: Replace version in docs | |
| if: steps.latest.outputs.version != steps.current.outputs.version | |
| run: | | |
| OLD="${{ steps.current.outputs.version }}" | |
| NEW="${{ steps.latest.outputs.version }}" | |
| # Target only the three forms the Flox version takes in MDX: | |
| # flox-X.Y.Z. download URLs (pkg, deb, rpm, SHA*SUMS) | |
| # Flox X.Y.Z display text | |
| # X.Y.Z indented output line in flox --version code blocks | |
| find . -name "*.mdx" -print0 | xargs -0 sed -i \ | |
| -e "s|flox-${OLD}\.|flox-${NEW}.|g" \ | |
| -e "s|Flox ${OLD}|Flox ${NEW}|g" \ | |
| -e "s|^ ${OLD}$| ${NEW}|g" | |
| echo "$NEW" > FLOX_VERSION | |
| - name: Create Pull Request | |
| if: steps.latest.outputs.version != steps.current.outputs.version | |
| uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8 | |
| with: | |
| token: "${{ secrets.MANAGED_FLOXBOT_GITHUB_ACCESS_TOKEN_REPO_SCOPE }}" | |
| add-paths: | | |
| **/*.mdx | |
| FLOX_VERSION | |
| commit-message: "chore: update Flox version to ${{ steps.latest.outputs.version }}" | |
| committer: "FloxBot <bot@flox.dev>" | |
| author: "FloxBot <bot@flox.dev>" | |
| branch: "chore-update-flox-version" | |
| delete-branch: true | |
| title: "chore: update Flox version to ${{ steps.latest.outputs.version }}" | |
| body: "This PR was automatically created by [Update Flox version workflow](https://github.com/flox/docs/actions/workflows/update-flox-version.yml)." | |
| labels: "team-developer-support" |