Some refinements #3492
This file contains 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: Containers | |
on: [push] | |
jobs: | |
build-containers: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: linz/action-typescript@v3 | |
- name: (Prod) Ensure tag exists | |
if: github.ref == 'refs/heads/master' && startsWith(github.event.head_commit.message, 'release:') | |
run: | | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* # see https://stackoverflow.com/a/60184319/9285308 | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
CURRENT_VERSION=$(node -p "require('./lerna.json').version") | |
git tag v${CURRENT_VERSION} -m v${CURRENT_VERSION} || true # Only create the tag if it doesn't exist | |
# Package all the files | |
- name: Bundle & Package all files | |
run: | | |
npx lerna run bundle --stream | |
npm pack --workspaces | |
env: | |
NODE_ENV: 'production' | |
- name: Set up Docker Qemu | |
id: qemu | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Setup tags | |
id: version | |
run: | | |
GIT_VERSION=$(git describe --tags --always --match 'v*') | |
GIT_VERSION_MAJOR=$(echo $GIT_VERSION | cut -d. -f1) | |
GIT_VERSION_MAJOR_MINOR=$(echo $GIT_VERSION | cut -d. -f1,2) | |
echo "version=${GIT_VERSION}" >> $GITHUB_OUTPUT | |
echo "version_major=${GIT_VERSION_MAJOR}" >> $GITHUB_OUTPUT | |
echo "version_major_minor=${GIT_VERSION_MAJOR_MINOR}" >> $GITHUB_OUTPUT | |
- name: Copy packages and files | |
run: | | |
# Files are packed into the base directory | |
cp *.tgz packages/server/ | |
cp *.tgz packages/cli/ | |
cp -r packages/lambda-tiler/static/ packages/server/ | |
cp -r packages/lambda-tiler/static/ packages/cli/ | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: '@basemaps/cli - Build and export to Docker' | |
uses: docker/build-push-action@v5 | |
with: | |
context: packages/cli | |
load: true | |
tags: | | |
ghcr.io/linz/basemaps/cli:latest | |
ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version }} | |
- name: '@basemaps/cli - Test' | |
run: | | |
docker run --rm ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version }} --help | |
- name: '@basemaps/cli - Build and push' | |
uses: docker/build-push-action@v5 | |
with: | |
context: packages/cli | |
platforms: linux/arm64,linux/amd64 | |
tags: | | |
ghcr.io/linz/basemaps/cli:latest | |
ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version }} | |
push: ${{github.ref == 'refs/heads/master' && startsWith(github.event.head_commit.message, 'release:') == false}} | |
- name: '@basemaps/cli - Build and push Major/Minor' | |
uses: docker/build-push-action@v5 | |
with: | |
context: packages/cli | |
platforms: linux/arm64,linux/amd64 | |
# Publish :v6 and :v6.38 tags when publishing a release | |
tags: | | |
ghcr.io/linz/basemaps/cli:latest | |
ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version_major }} | |
ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version_major_minor }} | |
ghcr.io/linz/basemaps/cli:${{ steps.version.outputs.version }} | |
push: ${{github.ref == 'refs/heads/master' && startsWith(github.event.head_commit.message, 'release:')}} | |
- name: '@basemaps/server - Build and export to Docker' | |
uses: docker/build-push-action@v5 | |
with: | |
context: packages/server | |
load: true | |
tags: | | |
ghcr.io/linz/basemaps/server:latest | |
ghcr.io/linz/basemaps/server:${{ steps.version.outputs.version }} | |
- name: '@basemaps/server - Test' | |
run: | | |
docker run --rm ghcr.io/linz/basemaps/server:${{ steps.version.outputs.version }} --version | |
- name: '@basemaps/server - Build and push' | |
uses: docker/build-push-action@v5 | |
with: | |
context: packages/server | |
platforms: linux/arm64,linux/amd64 | |
tags: | | |
ghcr.io/linz/basemaps/server:latest | |
ghcr.io/linz/basemaps/server:${{ steps.version.outputs.version }} | |
push: ${{github.ref == 'refs/heads/master' && startsWith(github.event.head_commit.message, 'release:') == false}} | |
- name: '@basemaps/server - Build and push Major/Minor' | |
uses: docker/build-push-action@v5 | |
with: | |
context: packages/server | |
platforms: linux/arm64,linux/amd64 | |
# Publish :v6 and :v6.38 tags when publishing a release | |
tags: | | |
ghcr.io/linz/basemaps/server:latest | |
ghcr.io/linz/basemaps/server:${{ steps.version.outputs.version_major }} | |
ghcr.io/linz/basemaps/server:${{ steps.version.outputs.version_major_minor }} | |
ghcr.io/linz/basemaps/server:${{ steps.version.outputs.version }} | |
push: ${{github.ref == 'refs/heads/master' && startsWith(github.event.head_commit.message, 'release:')}} | |