|
| 1 | +# Publishes each release to the package managers once the Release workflow has attached its |
| 2 | +# files: a Homebrew tap, the AUR, Fedora COPR and winget. Every channel is its own job, skips |
| 3 | +# itself when its secret is missing and never fails the others. Pre-releases are not published. |
| 4 | +# Run it by hand with a tag to republish a release. See packaging/README.md. |
| 5 | +# |
| 6 | +# Repository secrets: |
| 7 | +# HOMEBREW_TAP_DEPLOY_KEY - private half of an SSH deploy key with write access to |
| 8 | +# opengeos/homebrew-rustgis |
| 9 | +# AUR_SSH_PRIVATE_KEY - private SSH key of the AUR account that maintains rustgis-bin |
| 10 | +# COPR_CONFIG - the copr-cli config block from https://copr.fedorainfracloud.org/api/ |
| 11 | +# (the token expires after 180 days) |
| 12 | +# WINGET_TOKEN - classic token (public_repo) of the account owning the winget-pkgs fork |
| 13 | +name: Package managers |
| 14 | + |
| 15 | +on: |
| 16 | + workflow_run: |
| 17 | + workflows: [Release] |
| 18 | + types: [completed] |
| 19 | + workflow_dispatch: |
| 20 | + inputs: |
| 21 | + tag: |
| 22 | + description: Release tag to publish (defaults to the latest release) |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + |
| 26 | +permissions: |
| 27 | + contents: read |
| 28 | + |
| 29 | +concurrency: |
| 30 | + group: package-managers-${{ inputs.tag || github.event.workflow_run.head_branch || 'latest' }} |
| 31 | + cancel-in-progress: false |
| 32 | + |
| 33 | +jobs: |
| 34 | + release: |
| 35 | + name: Resolve the release |
| 36 | + # A workflow_run fires for trial runs too; only a published release's build counts. |
| 37 | + if: >- |
| 38 | + github.repository == 'opengeos/RustGIS' && |
| 39 | + (github.event_name != 'workflow_run' || |
| 40 | + (github.event.workflow_run.event == 'release' && |
| 41 | + github.event.workflow_run.conclusion == 'success')) |
| 42 | + runs-on: ubuntu-latest |
| 43 | + outputs: |
| 44 | + tag: ${{ steps.release.outputs.tag }} |
| 45 | + version: ${{ steps.release.outputs.version }} |
| 46 | + date: ${{ steps.release.outputs.date }} |
| 47 | + publish: ${{ steps.release.outputs.publish }} |
| 48 | + steps: |
| 49 | + - name: Resolve the release |
| 50 | + id: release |
| 51 | + env: |
| 52 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + REQUESTED_TAG: ${{ inputs.tag }} |
| 54 | + WORKFLOW_TAG: ${{ github.event.workflow_run.head_branch }} |
| 55 | + run: | |
| 56 | + tag="${REQUESTED_TAG:-${WORKFLOW_TAG:-}}" |
| 57 | + if [ -z "$tag" ]; then |
| 58 | + tag="$(gh api "repos/$GITHUB_REPOSITORY/releases/latest" --jq .tag_name)" |
| 59 | + fi |
| 60 | + json="$(gh api "repos/$GITHUB_REPOSITORY/releases/tags/$tag")" |
| 61 | + version="${tag#v}" |
| 62 | + publish=true |
| 63 | + if [ "$(jq -r .prerelease <<< "$json")" = true ] || ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 64 | + echo "::notice::$tag is a pre-release: not published to package managers." |
| 65 | + publish=false |
| 66 | + fi |
| 67 | + { |
| 68 | + echo "tag=$tag" |
| 69 | + echo "version=$version" |
| 70 | + echo "date=$(jq -r .published_at <<< "$json" | cut -dT -f1)" |
| 71 | + echo "publish=$publish" |
| 72 | + } >> "$GITHUB_OUTPUT" |
| 73 | +
|
| 74 | + homebrew: |
| 75 | + name: Homebrew tap |
| 76 | + needs: release |
| 77 | + if: needs.release.outputs.publish == 'true' |
| 78 | + runs-on: ubuntu-latest |
| 79 | + continue-on-error: true |
| 80 | + concurrency: |
| 81 | + group: homebrew-tap |
| 82 | + cancel-in-progress: false |
| 83 | + env: |
| 84 | + TAP_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@v7 |
| 87 | + if: env.TAP_KEY != '' |
| 88 | + with: |
| 89 | + persist-credentials: false |
| 90 | + |
| 91 | + - name: Update opengeos/homebrew-rustgis |
| 92 | + if: env.TAP_KEY != '' |
| 93 | + env: |
| 94 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + TAG: ${{ needs.release.outputs.tag }} |
| 96 | + VERSION: ${{ needs.release.outputs.version }} |
| 97 | + run: | |
| 98 | + gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern SHA256SUMS --dir "$RUNNER_TEMP" |
| 99 | + eval "$(ssh-agent -s)" |
| 100 | + ssh-add - <<< "$TAP_KEY" |
| 101 | + git clone --depth 1 git@github.com:opengeos/homebrew-rustgis.git "$RUNNER_TEMP/tap" |
| 102 | + packaging/homebrew/render.sh "$VERSION" "$RUNNER_TEMP/SHA256SUMS" "$RUNNER_TEMP/tap" |
| 103 | + cd "$RUNNER_TEMP/tap" |
| 104 | + git add Casks Formula |
| 105 | + if git diff --cached --quiet; then |
| 106 | + echo "The tap already has $VERSION." |
| 107 | + exit 0 |
| 108 | + fi |
| 109 | + git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \ |
| 110 | + commit -m "rustgis $VERSION" |
| 111 | + git push origin HEAD |
| 112 | +
|
| 113 | + aur: |
| 114 | + name: AUR |
| 115 | + needs: release |
| 116 | + if: needs.release.outputs.publish == 'true' |
| 117 | + runs-on: ubuntu-latest |
| 118 | + continue-on-error: true |
| 119 | + concurrency: |
| 120 | + group: aur |
| 121 | + cancel-in-progress: false |
| 122 | + env: |
| 123 | + AUR_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }} |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@v7 |
| 126 | + if: env.AUR_KEY != '' |
| 127 | + with: |
| 128 | + persist-credentials: false |
| 129 | + |
| 130 | + - name: Render the PKGBUILD |
| 131 | + if: env.AUR_KEY != '' |
| 132 | + env: |
| 133 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 134 | + TAG: ${{ needs.release.outputs.tag }} |
| 135 | + VERSION: ${{ needs.release.outputs.version }} |
| 136 | + run: | |
| 137 | + gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern SHA256SUMS --dir "$RUNNER_TEMP" |
| 138 | + mkdir -p aur |
| 139 | + packaging/aur/render.sh "$VERSION" "$RUNNER_TEMP/SHA256SUMS" > aur/PKGBUILD |
| 140 | + cat aur/PKGBUILD |
| 141 | +
|
| 142 | + - name: Push rustgis-bin to the AUR |
| 143 | + if: env.AUR_KEY != '' |
| 144 | + # Pinned to a commit: this step receives the AUR key. |
| 145 | + uses: KSXGitHub/github-actions-deploy-aur@084b0d9b15415bf9cdb65d44dad1efe37a354050 # v4.2.0 |
| 146 | + with: |
| 147 | + pkgname: rustgis-bin |
| 148 | + pkgbuild: aur/PKGBUILD |
| 149 | + commit_username: Qiusheng Wu |
| 150 | + commit_email: giswqs@gmail.com |
| 151 | + ssh_private_key: ${{ env.AUR_KEY }} |
| 152 | + commit_message: Update to ${{ needs.release.outputs.version }} |
| 153 | + allow_empty_commits: false |
| 154 | + updpkgsums: false |
| 155 | + |
| 156 | + copr: |
| 157 | + name: Fedora COPR |
| 158 | + needs: release |
| 159 | + if: needs.release.outputs.publish == 'true' |
| 160 | + runs-on: ubuntu-latest |
| 161 | + continue-on-error: true |
| 162 | + concurrency: |
| 163 | + group: copr |
| 164 | + cancel-in-progress: false |
| 165 | + env: |
| 166 | + COPR_CONFIG: ${{ secrets.COPR_CONFIG }} |
| 167 | + steps: |
| 168 | + - uses: actions/checkout@v7 |
| 169 | + if: env.COPR_CONFIG != '' |
| 170 | + with: |
| 171 | + persist-credentials: false |
| 172 | + |
| 173 | + - name: Build the source RPM and submit it to giswqs/rustgis |
| 174 | + if: env.COPR_CONFIG != '' |
| 175 | + env: |
| 176 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 177 | + TAG: ${{ needs.release.outputs.tag }} |
| 178 | + VERSION: ${{ needs.release.outputs.version }} |
| 179 | + DATE: ${{ needs.release.outputs.date }} |
| 180 | + run: | |
| 181 | + sudo apt-get update -qq |
| 182 | + sudo apt-get install -y -qq rpm appstream |
| 183 | + # Pinned: this step holds the COPR token. |
| 184 | + pipx install 'copr-cli==2.6' |
| 185 | + mkdir -p ~/.config |
| 186 | + (umask 077; printf '%s\n' "$COPR_CONFIG" > ~/.config/copr) |
| 187 | +
|
| 188 | + src="$HOME/rpmbuild/SOURCES" |
| 189 | + packaging/copr/render.sh "$VERSION" "$DATE" "$src" |
| 190 | + appstreamcli validate --no-net "$src/org.rustgis.RustGIS.metainfo.xml" |
| 191 | + gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --dir "$src" \ |
| 192 | + --pattern "rustgis-$VERSION-1.x86_64.rpm" --pattern "rustgis-$VERSION-1.aarch64.rpm" \ |
| 193 | + --pattern SHA256SUMS |
| 194 | + (cd "$src" && sha256sum --check --ignore-missing SHA256SUMS) |
| 195 | + srpm="$(rpmbuild -bs "$src/rustgis.spec" --define "_topdir $HOME/rpmbuild" | sed -n 's/^Wrote: //p')" |
| 196 | + [ -n "$srpm" ] || { echo "::error::rpmbuild wrote no source RPM"; exit 1; } |
| 197 | + copr-cli build --nowait giswqs/rustgis "$srpm" |
| 198 | +
|
| 199 | + winget: |
| 200 | + name: winget |
| 201 | + needs: release |
| 202 | + if: needs.release.outputs.publish == 'true' |
| 203 | + runs-on: ubuntu-latest |
| 204 | + continue-on-error: true |
| 205 | + concurrency: |
| 206 | + group: winget |
| 207 | + cancel-in-progress: false |
| 208 | + env: |
| 209 | + WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }} |
| 210 | + steps: |
| 211 | + - name: Open a pull request to microsoft/winget-pkgs |
| 212 | + if: env.WINGET_TOKEN != '' |
| 213 | + # Pinned to a commit: this step receives a token with access to the winget-pkgs fork. |
| 214 | + uses: vedantmgoyal9/winget-releaser@f29ed1ffd34f91223a2aebaa71beaab0901ff9fd # v2 |
| 215 | + with: |
| 216 | + identifier: OpenGeos.RustGIS |
| 217 | + release-tag: ${{ needs.release.outputs.tag }} |
| 218 | + installers-regex: 'windows-x86_64(-setup\.exe|\.msi)$' |
| 219 | + fork-user: giswqs |
| 220 | + token: ${{ env.WINGET_TOKEN }} |
0 commit comments