Skip to content

Commit 66d42b3

Browse files
authored
Merge branch 'main' into docs-gh-edit
2 parents 02f3458 + 4d49111 commit 66d42b3

File tree

6 files changed

+358
-136
lines changed

6 files changed

+358
-136
lines changed

.github/workflows/docker.yml

Lines changed: 98 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ on:
1616
branches:
1717
- main
1818
- releasebranch_*
19-
- '!releasebranch_7_*'
19+
- "!releasebranch_7_*"
2020
# tags: ['*.*.*']
2121
paths-ignore: [doc/**]
22+
pull_request:
23+
paths:
24+
- .github/workflows/docker.yml
25+
- Dockerfile
26+
- docker/**
27+
- "!docker/**.md"
28+
workflow_dispatch:
2229
release:
2330
types: [published]
2431

@@ -35,10 +42,17 @@ jobs:
3542
# For a release, e.g. 8.3.0, created tags are:
3643
# 8.3.0-alpine, 8.3.0-debian, 8.3.0-ubuntu and latest (with ubuntu)
3744
docker-os-matrix:
38-
name: build and push ${{ matrix.os }} for ${{ github.ref }}
39-
if: github.repository_owner == 'OSGeo'
45+
name: ${{ matrix.os }} for ${{ github.ref }}
4046
runs-on: ubuntu-latest
41-
47+
concurrency:
48+
group: >-
49+
${{ github.workflow }}-${{ matrix.os }}-${{ github.event_name }}-
50+
${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
51+
# Cancel in progress in pull requests.
52+
# Otherwise, limit to one in progress and one queued for each type.
53+
# Only the latest queued job per event type will be kept, older will be cancelled.
54+
# The already running job will be completed.
55+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
4256
strategy:
4357
matrix:
4458
os:
@@ -49,32 +63,78 @@ jobs:
4963
fail-fast: false
5064

5165
permissions:
66+
attestations: write
5267
contents: read
68+
id-token: write
5369
packages: write
5470

5571
steps:
5672
- name: Checkout
5773
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5874
with:
5975
fetch-depth: 0
76+
- name: Get the latest tag and release branches
77+
id: tag-branch
78+
run: |
79+
# Make sure tags are fetched
80+
git fetch --tags
81+
# Get sorted list of tags, keep the first that has a semver pattern (not RCs)
82+
latest_tag="$(git tag --sort=-v:refname \
83+
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \
84+
| head -n 1)"
85+
latest_rel_branch="$(git branch --all --list 'origin/*' \
86+
--contains "${latest_tag}" --format "%(refname:lstrip=3)")"
87+
echo "latest_tag=${latest_tag}" >> "${GITHUB_OUTPUT}"
88+
echo "latest_tag is: ${latest_tag}"
89+
echo "latest_rel_branch=${latest_rel_branch}" >> "${GITHUB_OUTPUT}"
90+
echo "latest_rel_branch is: ${latest_rel_branch}"
91+
- name: Get enable values for meta step
92+
id: enable
93+
run: |
94+
latest="${{
95+
(github.ref || format('{0}{1}', 'refs/tags/', github.event.release.tag_name))
96+
== format('refs/tags/{0}', steps.tag-branch.outputs.latest_tag)
97+
&& matrix.os == 'ubuntu' }}"
98+
current="${{
99+
( contains(fromJSON('["tag", "release"]'), github.event_name)
100+
&& (github.ref || format('{0}{1}', 'refs/tags/', github.event.release.tag_name))
101+
== format('refs/tags/{0}', steps.tag-branch.outputs.latest_tag)
102+
)
103+
|| github.ref == format('refs/heads/{0}', steps.tag-branch.outputs.latest_rel_branch)
104+
}}"
105+
echo "latest=${latest}" >> "${GITHUB_OUTPUT}"
106+
echo "latest is $latest"
107+
echo "current=${current}" >> "${GITHUB_OUTPUT}"
108+
echo "current is $current"
60109
- name: Docker meta
61110
id: meta
62111
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
63112
with:
64-
images: osgeo/grass-gis
113+
images: |
114+
name=docker.io/osgeo/grass-gis,enable=${{ github.repository_owner == 'OSGeo'
115+
&& github.event_name != 'pull_request' }}
116+
name=ghcr.io/${{ github.repository }}
65117
tags: |
66118
type=ref,event=tag
67119
type=ref,event=branch
68-
type=raw,value=current,enable=${{ github.ref == format('refs/heads/{0}', 'releasebranch_8_3') }}
69-
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/8.3') && matrix.os == 'ubuntu' }},suffix=
120+
type=ref,event=pr
121+
type=raw,value=current,enable=${{ steps.enable.outputs.current }}
122+
type=raw,value=latest,enable=${{ steps.enable.outputs.latest }},suffix=
70123
flavor: |
71124
latest=false
72125
suffix=-${{ matrix.os }}
73126
- name: Set up QEMU
74127
uses: docker/setup-qemu-action@4574d27a4764455b42196d70a065bc6853246a25 # v3.4.0
75128
- name: Set up Docker Buildx
76129
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3.9.0
77-
- name: Login to DockerHub
130+
- name: Login to GitHub Container Registry
131+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
132+
with:
133+
registry: ghcr.io
134+
username: ${{ github.actor }}
135+
password: ${{ secrets.GITHUB_TOKEN }}
136+
- name: Login to Docker Hub
137+
if: ${{ github.repository_owner == 'OSGeo' && github.event_name != 'pull_request' }}
78138
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
79139
with:
80140
username: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -83,12 +143,39 @@ jobs:
83143
id: docker_build
84144
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0
85145
with:
86-
push: true
87-
pull: true
146+
push: ${{ github.event_name != 'pull_request' }}
88147
context: .
89148
tags: ${{ steps.meta.outputs.tags }}
90149
file: docker/${{ matrix.os }}/Dockerfile
91-
cache-from: type=gha,scope=${{ matrix.os }}
150+
annotations: ${{ steps.meta.outputs.annotations }}
151+
provenance: mode=max
152+
sbom: true
153+
# Don't use cache for releases.
154+
no-cache: ${{ contains(fromJSON('["tag", "release"]'), github.event_name) && true }}
155+
# Don't use gha cache for releases. Cache is not used if `cache-from:` is empty
156+
cache-from: >-
157+
${{ !contains(fromJSON('["tag", "release"]'), github.event_name)
158+
&& format('type=gha,scope={0}', matrix.os) || '' }}
92159
cache-to: type=gha,mode=max,scope=${{ matrix.os }}
93160
- name: Image digest
94161
run: echo ${{ steps.docker_build.outputs.digest }}
162+
- name: Attest docker.io image
163+
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
164+
# If there isn't a digest, an annotation cannot be added
165+
if: >-
166+
${{ github.repository_owner == 'OSGeo' && github.event_name != 'pull_request'
167+
&& steps.docker_build.outputs.digest }}
168+
id: attest
169+
with:
170+
subject-name: docker.io/osgeo/grass-gis
171+
subject-digest: ${{ steps.docker_build.outputs.digest }}
172+
push-to-registry: ${{ github.repository_owner == 'OSGeo' && github.event_name != 'pull_request' }}
173+
- name: Attest ghcr.io image
174+
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
175+
# If there isn't a digest, an annotation cannot be added
176+
if: ${{ steps.docker_build.outputs.digest }}
177+
id: attest-ghcr
178+
with:
179+
subject-name: ghcr.io/${{ github.repository }}
180+
subject-digest: ${{ steps.docker_build.outputs.digest }}
181+
push-to-registry: ${{ github.event_name != 'pull_request' }}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
name: macOS distribute app
3+
4+
# Build and bundle macOS app
5+
6+
on:
7+
workflow_dispatch:
8+
schedule:
9+
# At 07:30 on Thursdays.
10+
# See https://crontab.guru/#30_7_*_*_THU
11+
- cron: "30 7 * * THU"
12+
push:
13+
tags:
14+
- '**'
15+
16+
permissions: {}
17+
18+
env:
19+
KEYCHAIN_PROFILE: notarytool-profile
20+
21+
jobs:
22+
macos_build:
23+
name: macOS distribute
24+
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}-${{
27+
matrix.name }}-${{ matrix.os }}
28+
cancel-in-progress: true
29+
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
matrix:
33+
name:
34+
- "x86_64"
35+
- "arm64"
36+
include:
37+
- name: "x86_64"
38+
os: macos-13
39+
deployment_target: 10.13
40+
- name: "arm64"
41+
os: macos-14
42+
deployment_target: 11
43+
fail-fast: false
44+
45+
steps:
46+
- name: Info
47+
run: |
48+
echo "macOS version $(sw_vers -productVersion)"
49+
echo "architecture $(uname -a)"
50+
- name: Disabling Spotlight
51+
run: sudo mdutil -a -i off
52+
- name: Uninstalling Homebrew
53+
run: |
54+
echo "Moving directories..."
55+
sudo mkdir /opt/local-off /opt/homebrew-off
56+
test ! -d /usr/local || /usr/bin/sudo /usr/bin/find /usr/local \
57+
-mindepth 1 -maxdepth 1 -type d -print -exec /bin/mv {} \
58+
/opt/local-off/ \;
59+
test ! -d /opt/homebrew || /usr/bin/sudo /usr/bin/find /opt/homebrew \
60+
-mindepth 1 -maxdepth 1 -type d -print -exec /bin/mv {} \
61+
/opt/homebrew-off/ \;
62+
echo "Removing files..."
63+
test ! -d /usr/local || /usr/bin/sudo /usr/bin/find /usr/local \
64+
-mindepth 1 -maxdepth 1 -type f -print -delete
65+
test ! -d /opt/homebrew || /usr/bin/sudo /usr/bin/find /opt/homebrew \
66+
-mindepth 1 -maxdepth 1 -type f -print -delete
67+
# Rehash to forget about the deleted files
68+
hash -r
69+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
70+
- name: Environment info
71+
shell: bash -el {0}
72+
run: |
73+
printenv | sort
74+
75+
- name: Install the Apple certificate and provisioning profile
76+
env:
77+
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
78+
MACOS_PROVISION_PROFILE: ${{ secrets.MACOS_PROVISION_PROFILE }}
79+
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
80+
MACOS_CERTIFICATE_NAME: ${{ secrets.MACOS_CERTIFICATE_NAME }}
81+
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.MACOS_CI_KEYCHAIN_PWD }}
82+
MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
83+
MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
84+
MACOS_NOTARIZATION_PWD: ${{ secrets.MACOS_NOTARIZATION_PWD }}
85+
run: |
86+
CERT="$RUNNER_TEMP/certificate.p12"
87+
INTERMEDIATE_CERT="$RUNNER_TEMP/DeveloperIDG2CA.cer"
88+
89+
curl -o "$INTERMEDIATE_CERT" https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer
90+
91+
echo -n "$MACOS_CERTIFICATE" | base64 --decode -o "$CERT"
92+
echo -n "$MACOS_PROVISION_PROFILE" | base64 --decode -o "$RUNNER_TEMP/embedded.provisionprofile"
93+
94+
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
95+
security default-keychain -s build.keychain
96+
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
97+
security set-keychain-settings -t 15000
98+
security import "$INTERMEDIATE_CERT" -k build.keychain -T /usr/bin/codesign
99+
security import "$CERT" -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
100+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" \
101+
build.keychain 1> /dev/null
102+
103+
echo "Create keychain profile"
104+
xcrun notarytool store-credentials "$KEYCHAIN_PROFILE" --apple-id "$MACOS_NOTARIZATION_APPLE_ID"\
105+
--team-id "$MACOS_NOTARIZATION_TEAM_ID" --password "$MACOS_NOTARIZATION_PWD"
106+
107+
- name: Create config file
108+
shell: bash -el {0}
109+
env:
110+
Config: ${HOME}/.config/grass/configure-build-${{ matrix.name }}.sh
111+
MACOS_CERTIFICATE_NAME: ${{ secrets.MACOS_CERTIFICATE_NAME }}
112+
run: |
113+
mkdir -p "${HOME}/.config/grass"
114+
echo sdk=\"$(xcrun --show-sdk-path)\" >> ${{ env.Config }}
115+
echo deployment_target=\"${{ matrix.deployment_target }}\" >> ${{ env.Config }}
116+
echo cs_ident=\"${MACOS_CERTIFICATE_NAME}\" >> ${{ env.Config }}
117+
echo cs_keychain_profile=\"${KEYCHAIN_PROFILE}\" >> ${{ env.Config }}
118+
echo cs_provisionprofile=\"${RUNNER_TEMP}/embedded.provisionprofile\" >> ${{ env.Config }}
119+
120+
- name: Build GRASS GIS app
121+
run: |
122+
./macos/build_grass_app.bash --with-liblas --notarize -o "${{ runner.temp }}"
123+
124+
- name: Upload DMG file as artifact
125+
if: ${{ success() && !cancelled() }}
126+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
127+
with:
128+
name: ${{ env.DMG_NAME }}
129+
path: ${{ env.DMG_FILE }}
130+
retention-days: 3

docker/alpine/Dockerfile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,17 @@ RUN echo " => Configure and compile grass" && \
167167
make install && \
168168
ldconfig /etc/ld.so.conf.d
169169

170+
# Build the GDAL-GRASS plugin
171+
# renovate: datasource=github-tags depName=OSGeo/gdal-grass
172+
ARG GDAL_GRASS_VERSION=1.0.3
173+
RUN git clone --branch $GDAL_GRASS_VERSION --depth 1 https://github.com/OSGeo/gdal-grass.git /src/gdal-grass
174+
WORKDIR /src/gdal-grass
175+
RUN cmake -B build -DAUTOLOAD_DIR=/usr/lib/gdalplugins -DBUILD_TESTING=OFF && \
176+
cmake --build build && \
177+
cmake --install build
178+
170179
# Get rid of version number here, restore in next stage via symbolic link
171-
RUN mv $(grass --config path) /usr/local/grass
180+
RUN mv /usr/local/grass85 /usr/local/grass
172181

173182
# Reduce the image size - Remove unnecessary grass files
174183
RUN cp /usr/local/grass/gui/wxpython/xml/module_items.xml module_items.xml; \
@@ -191,30 +200,21 @@ ENV GRASS_SKIP_MAPSET_OWNER_CHECK=1 \
191200
LC_ALL="en_US.UTF-8" \
192201
PYTHONPATH="/usr/local/grass/etc/python:$PYTHONPATH"
193202

194-
# Copy GRASS GIS from build image
203+
# Copy GRASS GIS and GDAL GRASS driver from build image
195204
COPY --from=build /usr/local/bin/grass /usr/local/bin/grass
196205
COPY --from=build /usr/local/grass* /usr/local/grass/
206+
COPY --from=build /usr/lib/gdalplugins/*_GRASS.so /usr/lib/gdalplugins/
197207
# Set GISBASE
198208
ENV GISBASE /usr/local/grass
199-
200-
# Build the GDAL-GRASS plugin
201-
# renovate: datasource=github-tags depName=OSGeo/gdal-grass
202-
ARG GDAL_GRASS_VERSION=1.0.3
203-
RUN git clone --branch $GDAL_GRASS_VERSION --depth 1 https://github.com/OSGeo/gdal-grass.git /src/gdal-grass
204-
WORKDIR /src/gdal-grass
205-
RUN cmake -B build -DAUTOLOAD_DIR=/usr/lib/gdalplugins -DBUILD_TESTING=OFF && \
206-
cmake --build build && \
207-
cmake --install build
208-
# Copy GDAL GRASS driver from build image
209-
COPY --from=build /usr/lib/gdalplugins/*_GRASS.so /usr/lib/gdalplugins/
209+
ENV GRASS_GISBASE /usr/local/grass
210210

211211
# run simple LAZ test
212212
COPY docker/testdata/simple.laz /tmp/
213213
COPY docker/testdata/test_grass_python.py docker/testdata/test_grass_session.py docker/alpine/grass_tests.sh /scripts/
214214

215215
# run GRASS GIS python session and scan the test LAZ file; some cleanup
216216
# also show installed version
217-
RUN ln -sf /usr/local/grass $(grass --config path); \
217+
RUN ln -sf /usr/local/grass /usr/local/grass85; \
218218
rm -rf /tmp/grasstest_epsg_25832; \
219219
$SHELL /scripts/grass_tests.sh; \
220220
python /scripts/test_grass_session.py && rm -rf /tmp/grasstest_epsg_25832; \

0 commit comments

Comments
 (0)