Repository navigation
ci: publish versioned Vale packages automatically #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+156
−10
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ce9d36c
ci: publish versioned Vale packages automatically
brendanclement 7197868
ci: verify existing Vale releases before skipping publication
brendanclement a694b69
ci: simplify Vale publication to the workflow
brendanclement b6c69e4
ci: compare Vale package files across runner platforms
brendanclement 9954fd9
ci: queue pending Vale package releases
brendanclement File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| name: Release Vale package | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "vale/LanceDB/meta.json" | ||
| - ".github/workflows/vale-release.yml" | ||
| pull_request: | ||
| paths: | ||
| - "vale/**" | ||
| - ".github/workflows/vale-release.yml" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: vale-package-${{ github.ref }} | ||
| queue: max | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| package: | ||
| runs-on: ubuntu-24.04 | ||
| outputs: | ||
| tag: ${{ steps.package.outputs.tag }} | ||
| exists: ${{ steps.package.outputs.exists }} | ||
| env: | ||
| VALE_VERSION: 3.24.0 | ||
| VALE_SHA256: 867534ddb678abca7f214bc4706ead0922bd5252ffe8035fc227013f66c8b214 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install Vale | ||
| run: | | ||
| archive="vale_${VALE_VERSION}_Linux_64-bit.tar.gz" | ||
| curl --fail --location --silent --show-error --output "$RUNNER_TEMP/$archive" \ | ||
| "https://github.com/vale-cli/vale/releases/download/v${VALE_VERSION}/$archive" | ||
| echo "${VALE_SHA256} $RUNNER_TEMP/$archive" | sha256sum --check | ||
| tar -xzf "$RUNNER_TEMP/$archive" -C "$RUNNER_TEMP" vale | ||
| echo "$RUNNER_TEMP" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Test the Vale rules | ||
| working-directory: vale/LanceDB | ||
| run: vale test --coverage styles ../tests | ||
|
|
||
| - name: Build and check the package | ||
| id: package | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| set -euo pipefail | ||
| version="$(jq -er '.version | select(type == "string")' vale/LanceDB/meta.json)" | ||
| [[ "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]] | ||
| tag="vale-lancedb-v$version" | ||
| revision=HEAD | ||
| exists=false | ||
| status=0 | ||
| git ls-remote --exit-code --tags origin "refs/tags/$tag" > /dev/null || status=$? | ||
| case "$status" in | ||
| 0) | ||
| git fetch --no-tags origin "refs/tags/$tag" | ||
| revision="$(git rev-parse 'FETCH_HEAD^{commit}')" | ||
| if [[ "$(git rev-parse "$revision:vale/LanceDB")" != "$(git rev-parse HEAD:vale/LanceDB)" ]]; then | ||
| echo "$tag has different package contents. Bump the version." >&2 | ||
| exit 1 | ||
| fi | ||
| [[ "$(gh release view "$tag" --repo "$GITHUB_REPOSITORY" --json isDraft,isPrerelease --jq '.isDraft or .isPrerelease')" == false ]] | ||
| gh release download "$tag" --repo "$GITHUB_REPOSITORY" --pattern LanceDB.zip --dir "$RUNNER_TEMP/published" | ||
| exists=true | ||
| ;; | ||
| 2) ;; | ||
| *) echo "Could not check existing tags; stopping." >&2; exit "$status" ;; | ||
| esac | ||
| # Build from the verified source commit. | ||
| git archive --format=zip --prefix=LanceDB/ \ | ||
| --mtime="$(git show -s --format=%cI "$revision")" \ | ||
| --output="$RUNNER_TEMP/LanceDB.zip" "$revision:vale/LanceDB" | ||
| if [[ "$exists" == true ]]; then | ||
| # ZIP timestamps can vary across platforms; compare the actual files. | ||
| unzip -q "$RUNNER_TEMP/LanceDB.zip" -d "$RUNNER_TEMP/built-files" | ||
| unzip -q "$RUNNER_TEMP/published/LanceDB.zip" -d "$RUNNER_TEMP/published-files" | ||
| diff -r "$RUNNER_TEMP/built-files" "$RUNNER_TEMP/published-files" | ||
| echo "Published package matches; skipping publication." | ||
| fi | ||
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | ||
| echo "exists=$exists" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| if: steps.package.outputs.exists != 'true' | ||
| with: | ||
| name: vale-package | ||
| path: ${{ runner.temp }}/LanceDB.zip | ||
| if-no-files-found: error | ||
|
|
||
| publish: | ||
| needs: package | ||
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && needs.package.outputs.exists != 'true' | ||
| runs-on: ubuntu-24.04 | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: vale-package | ||
| path: ${{ runner.temp }}/vale-package | ||
|
|
||
| - name: Publish a new version | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| RELEASE_TAG: ${{ needs.package.outputs.tag }} | ||
| run: | | ||
| # Atomically reserve the tag; never reuse a tag created by another run. | ||
| gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" \ | ||
| -f "ref=refs/tags/$RELEASE_TAG" -f "sha=$GITHUB_SHA" | ||
| gh release create "$RELEASE_TAG" "$RUNNER_TEMP/vale-package/LanceDB.zip" \ | ||
| --repo "$GITHUB_REPOSITORY" --verify-tag \ | ||
| --title "$RELEASE_TAG" --latest=false \ | ||
| --notes "Shared LanceDB Vale rules. Source commit: $GITHUB_SHA. This release does not publish the documentation site." | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.