Update build to include the latest swift-tool releases #175
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 build to include the latest swift-tool releases | |
| 'on': | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| schedule: | |
| - cron: 0 13 * * 1 | |
| workflow_dispatch: {} | |
| jobs: | |
| get-current-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| current-version: ${{ env.SWIFT_TOOL_VERSION }} | |
| latest-version: ${{ steps.cleaned-tool-release.outputs.release }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get current swift tool version | |
| run: echo "SWIFT_TOOL_VERSION=$(cat swift/swift-tool-version)" >> $GITHUB_ENV | |
| - id: tool-release | |
| name: Get latest swift-tool version | |
| uses: pozetroninc/github-action-get-latest-release@master | |
| with: | |
| owner: apple | |
| repo: pkl-swift | |
| excludes: prerelease, draft | |
| - id: cleaned-tool-release | |
| name: Strip leading "v" from the version string | |
| run: |- | |
| latestVersion="${{ steps.tool-release.outputs.release }}" | |
| echo "release=${latestVersion##*v}" >> $GITHUB_OUTPUT | |
| - name: Job Summary | |
| run: |- | |
| echo "### Versions" >> $GITHUB_STEP_SUMMARY | |
| echo "Current version: ${{ env.SWIFT_TOOL_VERSION }}" >> $GITHUB_STEP_SUMMARY | |
| echo "Latest version: ${{ steps.pkl-release.outputs.release }}" >> $GITHUB_STEP_SUMMARY | |
| update-swift-tool-version: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| needs: | |
| - get-current-version | |
| if: needs.get-current-version.outputs.current-version != needs.get-current-version.outputs.latest-version && github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Update swift/swift-tool-version file with latest release | |
| run: echo "${{ needs.get-current-version.outputs.latest-version }}" > swift/swift-tool-version | |
| - name: Setup node for gomplate | |
| uses: actions/setup-node@v4 | |
| - name: Update README and entrypoints | |
| run: |- | |
| npm install -g gomplate | |
| ./render-templates.sh | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| branch: update-swift-tool/feature/${{ needs.get-current-version.outputs.latest-version }}-pkl-lang | |
| title: Update swift-tool from ${{ needs.get-current-version.outputs.current-version }} to ${{ needs.get-current-version.outputs.latest-version }} | |
| assignees: emilymclean | |
| reviewers: emilymclean | |
| token: ${{ secrets.WORKER_PAT }} | |
| keep-alive: | |
| permissions: | |
| actions: write | |
| if: github.event_name == 'schedule' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: liskin/gh-workflow-keepalive@v1 |