Repository navigation
Create versioned Windows/Linux releases and support macOS uploads #112
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
Changes from all commits
94364dc
cc2bfb5
c705d73
ef2d1d1
eff0d67
d2ad592
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,41 +16,20 @@ jobs: | |
| name: Publish Windows and Linux installers | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Resolve matching build and release | ||
| - name: Select latest successful packaging run | ||
| id: resolve | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| GH_REPO: ${{ github.repository }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| gh api --paginate "repos/$GH_REPO/actions/workflows/desktop-packaging.yml/runs?event=workflow_dispatch&status=success&per_page=100" --jq '.workflow_runs[] | [.id, .head_sha] | @tsv' > "$RUNNER_TEMP/build-runs.tsv" | ||
| gh release list --limit 1000 --json tagName,isDraft --jq '.[] | select(.isDraft == false) | .tagName' > "$RUNNER_TEMP/release-tags.txt" | ||
| while IFS=$'\t' read -r run_id run_sha; do | ||
| [[ -n "$run_id" ]] || continue | ||
| while IFS= read -r tag; do | ||
| [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][A-Za-z0-9.-]+)?$ ]] || continue | ||
| ref_json="$(gh api "repos/$GH_REPO/git/ref/tags/$tag")" | ||
| tag_sha="$(jq -r '.object.sha' <<< "$ref_json")" | ||
| if [[ "$(jq -r '.object.type' <<< "$ref_json")" == "tag" ]]; then | ||
| tag_sha="$(gh api "repos/$GH_REPO/git/tags/$tag_sha" --jq '.object.sha')" | ||
| fi | ||
| if [[ "$run_sha" == "$tag_sha" ]]; then | ||
| echo "run_id=$run_id" >> "$GITHUB_OUTPUT" | ||
| echo "release_tag=$tag" >> "$GITHUB_OUTPUT" | ||
| echo "Selected build $run_id for release $tag ($run_sha)" >> "$GITHUB_STEP_SUMMARY" | ||
| exit 0 | ||
| fi | ||
| done < "$RUNNER_TEMP/release-tags.txt" | ||
| done < "$RUNNER_TEMP/build-runs.tsv" | ||
| echo "::error::No successful packaging run matches an existing published release tag." | ||
| echo "Successful packaging runs:" >&2 | ||
| head -n 10 "$RUNNER_TEMP/build-runs.tsv" >&2 | ||
| echo "Published release tags:" >&2 | ||
| head -n 20 "$RUNNER_TEMP/release-tags.txt" >&2 | ||
| echo "Create a release tag at the packaging run commit, or run Desktop packaging on the commit of an existing release tag." >&2 | ||
| echo "The publishing workflow will not silently attach binaries built from a different commit." >&2 | ||
| exit 1 | ||
| gh api "repos/$GH_REPO/actions/workflows/desktop-packaging.yml/runs?event=workflow_dispatch&status=success&per_page=100" > "$RUNNER_TEMP/runs.json" | ||
| run_id="$(jq -r '.workflow_runs[0].id // empty' "$RUNNER_TEMP/runs.json")" | ||
| run_sha="$(jq -r '.workflow_runs[0].head_sha // empty' "$RUNNER_TEMP/runs.json")" | ||
| [[ -n "$run_id" && -n "$run_sha" ]] || { echo "No successful packaging run found." >&2; exit 1; } | ||
| echo "run_id=$run_id" >> "$GITHUB_OUTPUT" | ||
| echo "run_sha=$run_sha" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Download packaging artifacts | ||
| env: | ||
|
|
@@ -63,6 +42,31 @@ jobs: | |
| mkdir -p "$RUNNER_TEMP/installers" | ||
| gh run download "$RUN_ID" --repo "$GH_REPO" --dir "$RUNNER_TEMP/installers" | ||
|
|
||
| - name: Resolve packaged version | ||
| id: version | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| GH_REPO: ${{ github.repository }} | ||
| RUN_SHA: ${{ steps.resolve.outputs.run_sha }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| mapfile -t manifests < <(find "$RUNNER_TEMP/installers" -name release-version.txt -type f) | ||
| [[ "${#manifests[@]}" == 2 ]] || { echo "Expected two version manifests." >&2; exit 1; } | ||
| version="$(cat "${manifests[0]}")" | ||
| [[ "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1 | ||
| [[ "$(cat "${manifests[1]}")" == "$version" ]] || { echo "Package versions differ." >&2; exit 1; } | ||
| if gh release view "$version" >/dev/null 2>&1; then | ||
| echo "Release $version already exists. Refusing to overwrite it." >&2 | ||
| exit 1 | ||
| fi | ||
| if gh api "repos/$GH_REPO/git/ref/tags/$version" >/dev/null 2>&1; then | ||
| echo "Tag $version already exists. Refusing to overwrite it." >&2 | ||
| exit 1 | ||
| fi | ||
| echo "release_tag=$version" >> "$GITHUB_OUTPUT" | ||
| echo "Publishing $version from commit $RUN_SHA" >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| - name: Validate installer files | ||
| shell: bash | ||
| run: | | ||
|
|
@@ -86,12 +90,12 @@ jobs: | |
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| GH_REPO: ${{ github.repository }} | ||
| RELEASE_TAG: ${{ steps.resolve.outputs.release_tag }} | ||
| RELEASE_TAG: ${{ steps.version.outputs.release_tag }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| shopt -s nullglob | ||
| files=("$RUNNER_TEMP"/upload/*) | ||
| (("${#files[@]}" > 0)) || exit 1 | ||
| gh release upload "$RELEASE_TAG" "${files[@]}" --repo "$GH_REPO" | ||
| gh release create "$RELEASE_TAG" "${files[@]}" --repo "$GH_REPO" --target "${{ steps.resolve.outputs.run_sha }}" --title "deepLocal $RELEASE_TAG" --notes "Windows and Linux desktop installers. macOS packages can be added separately." | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Whenever this workflow runs before the separate macOS uploader, this command publishes the new release without Useful? React with 👍 / 👎. |
||
| gh release view "$RELEASE_TAG" --repo "$GH_REPO" --json url --jq '.url' >> "$GITHUB_STEP_SUMMARY" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version command is truncated before its regex, quote, and command substitution are closed, so the following duplicated workflow steps are absorbed into the
runscalar until the unindented pipe at line 105 makes the document invalid YAML. GitHub cannot load or dispatchDesktop packagingin this state, preventing any Windows/Linux release artifacts from being built.Useful? React with 👍 / 👎.