Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLT-7540: Automate build process + code-signing for Windows/Mac #676

Closed
wants to merge 65 commits into from

Conversation

MusikPolice
Copy link
Contributor

@MusikPolice MusikPolice commented Dec 19, 2017

Before submitting, please confirm you've

Summary
A Jenkins Pipeline that is capable of building and code signing the desktop application for Windows, MacOS, and Linux. The corresponding Jenkins job is here.

Once merged, the job configuration will be updated so that this runs on any change to any branch in the desktop repository. That way, the existing mattermost-desktop-cut-release can still be used to cut releases. It creates a new branch, which this job will pick up and build.

We may want to think about artifact naming before we start using this to build releases. Currently, this pipeline removes version numbers from all artifacts that it builds, but we might not want to do that, since it could lead to confusion when trying to download the latest artifacts for release testing.

Finally, sorry for all of the commits to this branch. There isn't a great way to test this stuff other than to commit it and run it on Jenkins, since setting up my own Jenkins instance with EC2 spot instances and AMIs and such is a pain. Just look at the final script. The interim commits don't matter, and they'll all be squashed down to one when we merge anyway.

Issue link
https://mattermost.atlassian.net/browse/PLT-7540

@MusikPolice MusikPolice added the Work In Progress Not yet ready for review label Dec 19, 2017
@MusikPolice MusikPolice self-assigned this Dec 19, 2017
@jasonblais
Copy link
Contributor

@MusikPolice Is there a rough ETA on when this PR might be ready for review?

Really excited for this PR :)

@MusikPolice
Copy link
Contributor Author

@jasonblais There are three things left to do:

  1. Create a macOS Jenkins slave and move the mac build step to it so that it succeeds (right now, the build always fails because we can't build a macOS release on Jenkins' linux-based slaves)
  2. Add support for signing the Windows build. I almost have this working locally. More details in the linked JIRA ticket.
  3. Add support for signing the macOS build. This should be as simple as setting some environment variables prior to running the existing build step, but I'm still investigating.

As for timeline, if we just do step 1, this is ready to be deployed, and we can use it to replace Circle CI with Jenkins. Steps 2 and 3 are an enhancement that remove the existing manual code signing step that we have to do with every release.

@jasonblais jasonblais added this to the v4.0.0 milestone Jan 5, 2018
@jasonblais jasonblais modified the milestones: v4.0.0, v4.1.0 Jan 18, 2018
steps {
echo 'Building Mattermost Desktop App'
sh 'rm -rf release'
sh 'npm install'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use yarn to respect yarn.lock.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated command to use yarn install, @yuya-oc can you give this another review?

echo 'Building Mattermost Desktop App'
sh 'rm -rf release'
sh 'rm -rf codesign-*'
sh 'npm install'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use yarn to respect yarn.lock.


echo 'Building Mattermost Desktop App'
sh 'rm -rf release'
sh 'npm install'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use yarn to respect yarn.lock.

sh 'mv release/mattermost-desktop-*.tar.gz release/mattermost-desktop-linux-x64.tar.gz'
sh 'mv release/tmp-linux-ia32.tar.gz release/mattermost-desktop-linux-ia32.tar.gz'
sh 'mv release/mattermost-desktop_*_i386.deb release/mattermost-desktop-linux-i386.deb'
sh 'mv release/mattermost-desktop_*_amd64.deb release/mattermost-desktop-linux-amd64.deb'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonblais
Copy link
Contributor

@MusikPolice Is the plan to now only code sign the release branches, similar to what we do for the server?

@MusikPolice
Copy link
Contributor Author

@jasonblais I think so. I'll have to look into how to actually make that secure though. I don't want to just blindly sign any branch that as a "release" prefix on it's name, because any developer can create one.

We may need to add an optional boolean parameter that controls whether or not the job will sign the builds. This parameter would default to false, but when the existing desktop-cut-release job is manually triggered, it would kick off this job with the parameter set to true. That way, only manually started jobs could actually code sign artifacts.

@jasonblais
Copy link
Contributor

@MusikPolice Yeah, that would make sense.

It might also be worthwhile to check how the code signing is done for the server.

@yuya-oc
Copy link
Contributor

yuya-oc commented Feb 19, 2018

@MusikPolice Just curious, and not required for now. electron-builder has a feature to do code-signing.

https://www.electron.build/code-signing

Are you considering to use it in future? I think that the feature would make scripts simple.

@jasonblais
Copy link
Contributor

@AndersonWebStudio I believe you're taking over this PR now. If you have any questions, don't hesitate to let @yuya-oc or Joram know.

@amyblais amyblais removed this from the v4.1.0 milestone Mar 21, 2018
Copy link
Contributor

@yuya-oc yuya-oc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost looks good to me. Now v4.1 uses different artifact name, so please check my comments.

sh '''#!/bin/bash
WIN_IA32_SETUP_VERSION=$(awk -F' ' '{print $3}' <<< $(awk -F'-' '{print $2}' <<< $(ls release/win-ia32/Mattermost\\ Setup\\ *-ia32.exe)))
echo "WIN_IA32_SETUP_VERSION is $WIN_IA32_SETUP_VERSION"
mv release/win-ia32/Mattermost\\ Setup\\ $WIN_IA32_SETUP_VERSION-ia32.exe release/mattermost-setup-$WIN_IA32_SETUP_VERSION-win32.exe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release/win-ia32 -> release/squirrel-windows-ia32

TEMP_VERSION=$(awk -F' ' '{print $3}' <<< $(ls release/win/Mattermost\\ Setup\\ *[^ia32].exe))
WIN_64_SETUP_VERSION=${TEMP_VERSION%%.exe}
echo "WIN_64_SETUP_VERSION is $WIN_64_SETUP_VERSION"
mv release/win/Mattermost\\ Setup\\ $WIN_64_SETUP_VERSION.exe release/mattermost-setup-$WIN_64_SETUP_VERSION-win64.exe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release/win -> release/squirrel-windows

echo 'Packaging for MacOS'
sh '''#!/bin/bash
npm run package:mac
MACOS_VERSION=$(awk -F'-' '{print $2 }' <<< $(ls release/Mattermost-*-mac.tar.gz))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tar.gz -> zip

npm run package:mac
MACOS_VERSION=$(awk -F'-' '{print $2 }' <<< $(ls release/Mattermost-*-mac.tar.gz))
echo "MACOS_VERSION is $MACOS_VERSION"
mv release/Mattermost-*-mac.tar.gz release/mattermost-desktop-$MACOS_VERSION-macos.tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tar.gz -> zip

echo "MACOS_VERSION is $MACOS_VERSION"
mv release/Mattermost-*-mac.tar.gz release/mattermost-desktop-$MACOS_VERSION-macos.tar.gz
'''
archiveArtifacts artifacts: 'release/mattermost-desktop-*-macos.tar.gz'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tar.gz -> zip

@@ -0,0 +1,138 @@
#!/usr/bin/env groovy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, is shebang needed? In the Jenkinsfile doc, shebang is not used.

https://jenkins.io/doc/book/pipeline/jenkinsfile/

}
}
stage('Build Windows') {
agent any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, can we use Windows slave in future? We would be able to use Node's native modules.

agent any
steps {
echo 'Building Mattermost Desktop App'
sh '''#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that set -e is needed for each bash script in order to stop the pipeline as script error when an error occurred in a certain command.

@yuya-oc
Copy link
Contributor

yuya-oc commented May 3, 2018

@AndersonWebStudio After we merge this, how do we cut new release? Is it enough just pushing a tag?

@GoldUniform
Copy link
Contributor

We have moved this pipeline to the shared-pipelines repo, this pull request no longer needs to be merged.

@GoldUniform GoldUniform deleted the PLT-7540 branch May 16, 2018 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants