Skip to content

Merge pull request #1501 from session-foundation/feature/update-crowd… #974

Merge pull request #1501 from session-foundation/feature/update-crowd…

Merge pull request #1501 from session-foundation/feature/update-crowd… #974

# There is a fair bit of duplication here, but it is the best to save our github free minutes for now.
# We could save and restore cache to different jobs but that takes roughly 3 minutes to save,
# so better run them in parrallel instead.
name: Session Desktop
on:
push:
branches:
- master
- dev
- 'release/**'
- 'ci/**'
pull_request:
branches:
- dev
- 'release/**'
- 'ci/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
# we only want to publish on "push to master" or alpha releases. When we don't want to publish, we want to upload artefacts
SHOULD_PUBLISH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
SHOULD_PUBLISH_ALPHA: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && contains(github.ref, '-alpha.') }}
jobs:
build_linux:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
# this needs to be a valid target of https://www.electron.build/linux#target
pkg_to_build: ['deb', 'rpm', 'freebsd', 'AppImage']
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- run: git config --global core.autocrlf false
- name: Checkout git repo
uses: actions/checkout@v4
- name: Setup & Build
uses: ./actions/setup_and_build
with:
cache_suffix: ${{ matrix.pkg_to_build }}
- name: Lint Files
# no need to lint files on all platforms
run: yarn lint
- name: Enforce yarn.lock has no duplicates
uses: ./actions/deduplicate_fail
# we want to test on all platforms since some are testing the rendered menus (and are dependent on the platform)
- name: Unit Test
run: yarn test
- name: Make release build but do not publish ${{ matrix.pkg_to_build }}
# always run this, except on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'false' && env.SHOULD_PUBLISH_ALPHA == 'false' }}
run: |
sed -i 's/"target": "deb"/"target": "${{ matrix.pkg_to_build }}"/g' package.json && yarn build-release
- name: Upload artefacts ${{ matrix.pkg_to_build }}
# always run this, except on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'false' && env.SHOULD_PUBLISH_ALPHA == 'false' }}
uses: ./actions/upload_prod_artefacts
with:
upload_prefix: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.pkg_to_build }}
- name: Make release build & publish ${{ matrix.pkg_to_build }}
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
run: |
sed -i 's/"target": "deb"/"target": "${{ matrix.pkg_to_build }}"/g' package.json && yarn build-release-publish
- name: Backup release metadata
# only run this on "push" to "master" or alpha releases
# Note: The jobs are overwriting each other's latest-linux.yml.
# So, we upload all of them as artifacts, and then merge them (see `post_build_linux`)
# note: freebsd does not generate a latest-linux.yml file so we exclude it
if: ${{ (env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true') && matrix.pkg_to_build != 'freebsd' }}
shell: bash
run: |
mv dist/latest-linux.yml dist/latest-linux-${{ matrix.pkg_to_build }}-${{ github.sha }}.yml
- name: Upload release metadata
# only run this on "push" to "master" or alpha releases
if: ${{ (env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true') && matrix.pkg_to_build != 'freebsd' }}
uses: actions/upload-artifact@v4
with:
name: latest-linux-${{ matrix.pkg_to_build }}-${{ github.sha }}.yml
path: dist/latest-linux-${{ matrix.pkg_to_build }}-${{ github.sha }}.yml
post_build_linux:
needs: [build_linux]
runs-on: ubuntu-22.04
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout git repo
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
uses: actions/checkout@v4
# We only need a few files in this run, no point cloning everything
with:
sparse-checkout: |
package.json
build/setup-release-combine.sh
build/release-notes.md
build/release-notes-alpha.md
sparse-checkout-cone-mode: false
- name: Get version tag from package.json
id: get_version
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
run: |
version=$(node -p "require('./package.json').version")
echo "VERSION_TAG=$version" >> "$GITHUB_OUTPUT"
- name: Download release metadata
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
uses: actions/download-artifact@v4
with:
pattern: latest-linux-*-${{ github.sha }}.yml
path: dist
merge-multiple: true
- name: Combine release metadata
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
run: |
./build/setup-release-combine.sh ${{ github.sha }} linux
- name: Upload changes to draft release
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.get_version.outputs.VERSION_TAG }}
name: 'Session ${{ steps.get_version.outputs.VERSION_TAG }}'
draft: true
bodyFile: ${{ env.SHOULD_PUBLISH_ALPHA == 'true' && 'build/release-notes-alpha.md' || 'build/release-notes.md' }}
artifacts: 'dist/latest-linux.yml'
allowUpdates: true
omitNameDuringUpdate: true
replacesArtifacts: true
updateOnlyUnreleased: true
build_windows:
runs-on: windows-2022
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- run: git config --global core.autocrlf false
- name: Checkout git repo
uses: actions/checkout@v4
- name: Setup & Build
uses: ./actions/setup_and_build
with:
cache_suffix: 'windows_x64'
# we want to test on all platforms since some are testing the rendered menus (and are dependent on the platform)
- name: Unit Test
run: yarn test
- name: Make release build but do not publish
# always run this, except on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'false' && env.SHOULD_PUBLISH_ALPHA == 'false' }}
run: yarn build-release
- name: Upload artefacts
# always run this, except on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'false' && env.SHOULD_PUBLISH_ALPHA == 'false' }}
uses: ./actions/upload_prod_artefacts
with:
upload_prefix: ${{ runner.os }}-${{ runner.arch }}
- name: Make release build & publish
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
run: yarn build-release-publish # No other args needed for windows publish
# We want both arm64 and intel mac builds, and according to this https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources macos-14 and above is always arm64 and macos-13 is the last intel runner
# NOTE x64 builds made on an arm64 host will not bundle the native modules correctly https://github.com/electron-userland/electron-builder/issues/8646
build_mac_arm64:
runs-on: macos-14
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAC_CERTIFICATE: ${{ secrets.MAC_CERTIFICATE }}
MAC_CERTIFICATE_PASSWORD: ${{ secrets.MAC_CERTIFICATE_PASSWORD }}
SIGNING_APPLE_ID: ${{ secrets.SIGNING_APPLE_ID }}
SIGNING_APP_PASSWORD: ${{ secrets.SIGNING_APP_PASSWORD }}
SIGNING_TEAM_ID: ${{ secrets.SIGNING_TEAM_ID }}
steps:
- run: git config --global core.autocrlf false
- name: Checkout git repo
uses: actions/checkout@v4
- name: Setup & Build
uses: ./actions/setup_and_build
with:
cache_suffix: mac-arm64
# we want to test on all platforms since some are testing the rendered menus (and are dependent on the platform)
- name: Unit Test
run: yarn test
- name: Make release build arm64
uses: ./actions/make_release_build
with:
architecture: arm64
should_publish: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
build_mac_x64:
runs-on: macos-13
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAC_CERTIFICATE: ${{ secrets.MAC_CERTIFICATE }}
MAC_CERTIFICATE_PASSWORD: ${{ secrets.MAC_CERTIFICATE_PASSWORD }}
SIGNING_APPLE_ID: ${{ secrets.SIGNING_APPLE_ID }}
SIGNING_APP_PASSWORD: ${{ secrets.SIGNING_APP_PASSWORD }}
SIGNING_TEAM_ID: ${{ secrets.SIGNING_TEAM_ID }}
steps:
- run: git config --global core.autocrlf false
- name: Checkout git repo
uses: actions/checkout@v4
- name: Setup & Build
uses: ./actions/setup_and_build
with:
cache_suffix: mac-x64
# we want to test on all platforms since some are testing the rendered menus (and are dependent on the platform)
- name: Unit Test
run: yarn test
- name: Make release build x64
uses: ./actions/make_release_build
with:
architecture: x64
should_publish: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
post_build_mac:
needs: [build_mac_arm64, build_mac_x64]
runs-on: ubuntu-22.04
steps:
- name: Checkout git repo
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
uses: actions/checkout@v4
# We only need the package.json file in this run (to extract the version being built)
with:
sparse-checkout: |
package.json
build/setup-release-combine.sh
- name: Get version tag from package.json
id: get_version
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
run: |
version=$(node -p "require('./package.json').version")
echo "VERSION_TAG=$version" >> "$GITHUB_OUTPUT"
- name: Download release metadata
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
uses: actions/download-artifact@v4
with:
pattern: latest-mac-*-${{ github.sha }}.yml
path: dist
merge-multiple: true
- name: Combine release metadata
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
run: |
./build/setup-release-combine.sh ${{ github.sha }} mac
- name: Upload changes to draft release
# only run this on "push" to "master" or alpha releases
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.get_version.outputs.VERSION_TAG }}
draft: true
name: 'Draft'
artifacts: 'dist/latest-mac.yml'
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
replacesArtifacts: true
updateOnlyUnreleased: true