Release - build & publish modules and server, build & publish docker containers #4
Workflow file for this run
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
| name: Release - build & publish modules and server, build & publish docker containers | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| server-admin-ui-dependencies: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - run: | | |
| if [[ "$(npm view @signalk/server-admin-ui-dependencies version)" != "$(awk '/"version":/{gsub(/("|",)/,"",$2);print $2}' packages/server-admin-ui-dependencies/package.json)" ]]; then | |
| cd packages/server-admin-ui-dependencies | |
| npm install --package-lock-only | |
| npm ci && npm cache clean --force | |
| npm publish --access public | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| server-admin-ui: | |
| runs-on: ubuntu-latest | |
| needs: server-admin-ui-dependencies | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - run: | | |
| if [[ "$(npm view @signalk/server-admin-ui version)" != "$(awk '/"version":/{gsub(/("|",)/,"",$2);print $2}' packages/server-admin-ui/package.json)" ]]; then | |
| cd packages/server-admin-ui | |
| npm install --package-lock-only | |
| npm ci && npm cache clean --force | |
| npm publish --access public | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| server-api: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - run: | | |
| if [[ "$(npm view @signalk/server-api version)" != "$(awk '/"version":/{gsub(/("|",)/,"",$2);print $2}' packages/server-api/package.json)" ]]; then | |
| cd packages/server-api | |
| npm install --package-lock-only | |
| npm ci && npm cache clean --force | |
| npm publish --access public | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| streams: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - run: | | |
| if [[ "$(npm view @signalk/streams version)" != "$(awk '/"version":/{gsub(/("|",)/,"",$2);print $2}' packages/streams/package.json)" ]]; then | |
| cd packages/streams | |
| npm install --package-lock-only | |
| npm ci && npm cache clean --force | |
| npm publish --access public | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| resources-provider-plugin: | |
| needs: server-api | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - run: | | |
| if [[ "$(npm view @signalk/resources-provider version)" != "$(awk '/"version":/{gsub(/("|",)/,"",$2);print $2}' packages/resources-provider-plugin/package.json)" ]]; then | |
| # to disable workspaces, otherwise npm will not install @signalk/server-api | |
| rm package.json | |
| cd packages/resources-provider-plugin | |
| npm install --package-lock-only | |
| npm ci && npm cache clean --force | |
| npm publish --access public | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| signalk-server: | |
| runs-on: ubuntu-latest | |
| needs: [server-admin-ui, server-api, streams, resources-provider-plugin] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Set tag variable | |
| id: vars | |
| run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
| - name: Install, build & publish | |
| run: | | |
| npm install --package-lock-only | |
| npm ci && npm cache clean --force | |
| if [[ "$tag" == *beta* ]]; | |
| then | |
| npm publish --tag beta | |
| else | |
| npm publish | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| release: | |
| permissions: | |
| contents: write | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| needs: signalk-server | |
| steps: | |
| - name: Build Changelog | |
| id: github_release | |
| uses: mikepenz/release-changelog-builder-action@v5 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }} | |
| - name: Create Release (archived, need to be updated to use the new action) | |
| uses: actions/create-release@v1 | |
| with: | |
| tag_name: ${{ github.ref }} | |
| release_name: ${{ github.ref }} | |
| body: ${{steps.github_release.outputs.changelog}} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }} | |
| docker_images: | |
| needs: signalk-server | |
| strategy: | |
| matrix: | |
| os: [22.04, 24.04] | |
| vm: [ubuntu-latest, ubuntu-24.04-arm] | |
| include: | |
| - vm: ubuntu-latest | |
| arch: amd | |
| platform: linux/amd64 | |
| - vm: ubuntu-24.04-arm | |
| arch: arm | |
| platform: linux/arm64,linux/arm/v7 | |
| runs-on: ${{ matrix.vm }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to ghcr.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_PAT }} | |
| - name: Set TAG for build-args | |
| id: vars | |
| run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
| - name: Modify Dockerfile_rel for build | |
| run: | | |
| sed -i \ | |
| "s|cr.signalk.io/signalk/signalk-server-base:latest|ghcr.io/signalk/signalk-server-base:latest-${{ matrix.os }}|g" \ | |
| ./docker/Dockerfile_rel | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./docker/Dockerfile_rel | |
| platforms: ${{ matrix.platform }} | |
| push: true | |
| tags: ghcr.io/signalk/signalk-server:${{ matrix.arch }}-${{ matrix.os }}-${{ github.run_id }} | |
| build-args: | | |
| TAG=${{ steps.vars.outputs.tag }} | |
| create-and-push-manifest: | |
| needs: docker_images | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| os: [22.04, 24.04] | |
| include: | |
| - os: 22.04 | |
| tag: latest | |
| - os: 24.04 | |
| tag: latest | |
| suffix: -24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Docker meta | |
| id: docker_meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| signalk/signalk-server | |
| ghcr.io/signalk/signalk-server | |
| tags: | | |
| type=semver,pattern={{raw}} | |
| type=semver,pattern=v{{major}},enable=${{ !contains(github.ref, 'beta') }} | |
| type=semver,pattern=v{{major}}.{{minor}},enable=${{ !contains(github.ref, 'beta') }} | |
| type=raw,value=${{ matrix.tag }},enable=${{ !contains(github.ref, 'beta') }} | |
| flavor: | | |
| suffix=${{ matrix.suffix }} | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: signalkci | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to ghcr.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_PAT }} | |
| - name: Create and push multi-arch manifest to GHCR and Docker Hub | |
| uses: int128/docker-manifest-create-action@v2 | |
| with: | |
| tags: | | |
| ${{ steps.docker_meta.outputs.tags }} | |
| sources: | | |
| ghcr.io/signalk/signalk-server:amd-${{ matrix.os }}-${{ github.run_id }} | |
| ghcr.io/signalk/signalk-server:arm-${{ matrix.os }}-${{ github.run_id }} | |
| housekeeping: | |
| needs: create-and-push-manifest | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| steps: | |
| - name: Remove Docker Image from GHCR | |
| uses: dataaxiom/ghcr-cleanup-action@v1 | |
| with: | |
| packages: signalk-server | |
| delete-untagged: true | |
| delete-tags: amd-22.04-${{ github.run_id }},arm-22.04-${{ github.run_id }},amd-24.04-${{ github.run_id }},arm-24.04-${{ github.run_id }} | |
| token: ${{ secrets.GHCR_PAT }} | |
| deploy_fly: | |
| runs-on: ubuntu-latest | |
| needs: create-and-push-manifest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup flyctl | |
| uses: superfly/flyctl-actions/setup-flyctl@master | |
| - name: Set TAG for build-arg | |
| id: vars | |
| run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
| - name: Deploy demo.signalk.org at fly.io | |
| working-directory: ./fly_io/demo_signalk_org | |
| run: flyctl deploy --remote-only --build-arg SK_VERSION=${{ steps.vars.outputs.tag }} | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |