forked from git-for-windows/git
-
Notifications
You must be signed in to change notification settings - Fork 106
Implement workflow to create GitHub release with attached git installers
#399
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
091c097
release: create initial Windows installer build workflow
vdye 9ecd68a
release: add Mac OSX installer build
vdye e18a727
release: build unsigned Ubuntu .deb package
vdye e76aa35
release: add signing step for .deb package
vdye 2147b22
release: create draft GitHub release with packages & installers
vdye 1ba931c
fixup! release: create initial Windows installer build workflow
vdye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| name: build-git-installers | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v[0-9]*vfs*' # matches "v<number><any characters>vfs<any characters>" | ||
|
|
||
| env: | ||
| INCLUDE_SCALAR: 1 | ||
|
|
||
| jobs: | ||
| # Check prerequisites for the workflow | ||
| prereqs: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| AZ_SUB: ${{ secrets.AZURE_SUBSCRIPTION }} | ||
| AZ_CREDS: ${{ secrets.AZURE_CREDENTIALS }} | ||
| outputs: | ||
| tag_name: ${{ steps.tag.outputs.name }} # The full name of the tag, e.g. v2.32.0.vfs.0.0 | ||
| tag_version: ${{ steps.tag.outputs.version }} # The version number (without preceding "v"), e.g. 2.32.0.vfs.0.0 | ||
| steps: | ||
| - name: Determine tag to build | ||
| run: | | ||
| echo "::set-output name=name::${GITHUB_REF#refs/tags/}" | ||
| echo "::set-output name=version::${GITHUB_REF#refs/tags/v}" | ||
| id: tag | ||
| - name: Clone git | ||
| uses: actions/checkout@v2 | ||
| - name: Validate the tag identified with trigger | ||
| run: | | ||
| die () { | ||
| echo "::error::$*" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| # `actions/checkout` only downloads the peeled tag (i.e. the commit) | ||
| git fetch origin +$GITHUB_REF:$GITHUB_REF | ||
|
|
||
| # Verify that the tag is annotated | ||
| test $(git cat-file -t "$GITHUB_REF") == "tag" || die "Tag ${{ steps.tag.outputs.name }} is not annotated" | ||
|
|
||
| # Verify tag follows rules in GIT-VERSION-GEN (i.e., matches the specified "DEF_VER" in | ||
| # GIT-VERSION-FILE) and matches tag determined from trigger | ||
| make GIT-VERSION-FILE | ||
| test "${{ steps.tag.outputs.version }}" == "$(sed -n 's/^GIT_VERSION = //p'< GIT-VERSION-FILE)" || die "GIT-VERSION-FILE tag does not match ${{ steps.tag.outputs.name }}" | ||
| # End check prerequisites for the workflow | ||
|
|
||
| # Build Windows installers (x86_64 installer & portable) | ||
| windows_pkg: | ||
| runs-on: windows-latest | ||
| needs: prereqs | ||
| env: | ||
| GPG_OPTIONS: "--batch --yes --no-tty --list-options no-show-photos --verify-options no-show-photos --pinentry-mode loopback" | ||
| HOME: "${{github.workspace}}\\home" | ||
| USERPROFILE: "${{github.workspace}}\\home" | ||
| steps: | ||
| - name: Configure user | ||
| shell: bash | ||
| run: | ||
| USER_NAME="${{github.actor}}" && | ||
| USER_EMAIL="${{github.actor}}@users.noreply.github.com" && | ||
| mkdir -p "$HOME" && | ||
| git config --global user.name "$USER_NAME" && | ||
| git config --global user.email "$USER_EMAIL" && | ||
| echo "PACKAGER=$USER_NAME <$USER_EMAIL>" >>$GITHUB_ENV | ||
| - uses: git-for-windows/setup-git-for-windows-sdk@v1 | ||
| with: | ||
| flavor: build-installers | ||
| - name: Clone build-extra | ||
| shell: bash | ||
| run: | | ||
| git clone --single-branch -b main https://github.com/git-for-windows/build-extra /usr/src/build-extra | ||
| - name: Clone git | ||
| shell: bash | ||
| run: | | ||
| # Since we cannot directly clone a specified tag (as we would a branch with `git clone -b <branch name>`), | ||
| # this clone has to be done manually (via init->fetch->reset). | ||
|
|
||
| tag_name="${{ needs.prereqs.outputs.tag_name }}" && | ||
| git -c init.defaultBranch=main init && | ||
| git remote add -f origin https://github.com/git-for-windows/git && | ||
| git fetch "https://github.com/${{github.repository}}" refs/tags/${tag_name}:refs/tags/${tag_name} && | ||
| git reset --hard ${tag_name} | ||
| - name: Prepare home directory for code-signing | ||
| env: | ||
| CODESIGN_P12: ${{secrets.CODESIGN_P12}} | ||
| CODESIGN_PASS: ${{secrets.CODESIGN_PASS}} | ||
| if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != '' | ||
| shell: bash | ||
| run: | | ||
| cd home && | ||
| mkdir -p .sig && | ||
| echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >.sig/codesign.p12 && | ||
| echo -n "$CODESIGN_PASS" >.sig/codesign.pass | ||
| git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"' | ||
| - name: Prepare home directory for GPG signing | ||
| if: env.GPGKEY != '' | ||
| shell: bash | ||
| run: | | ||
| # This section ensures that the identity for the GPG key matches the git user identity, otherwise | ||
| # signing will fail | ||
|
|
||
| echo '${{secrets.PRIVGPGKEY}}' | tr % '\n' | gpg $GPG_OPTIONS --import && | ||
| info="$(gpg --list-keys --with-colons "${GPGKEY%% *}" | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" && | ||
| git config --global user.name "${info% <*}" && | ||
| git config --global user.email "<${info#*<}" | ||
| env: | ||
| GPGKEY: ${{secrets.GPGKEY}} | ||
| - name: Build mingw-w64-x86_64-git | ||
| env: | ||
| GPGKEY: "${{secrets.GPGKEY}}" | ||
| shell: bash | ||
| run: | | ||
| set -x | ||
|
|
||
| # Make sure that there is a `/usr/bin/git` that can be used by `makepkg-mingw` | ||
| printf '#!/bin/sh\n\nexec /mingw64/bin/git.exe "$@"\n' >/usr/bin/git && | ||
|
|
||
| # Restrict `PATH` to MSYS2 and to Visual Studio (to let `cv2pdb` find the relevant DLLs) | ||
| PATH="/mingw64/bin:/usr/bin:/C/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64:/C/Windows/system32" | ||
|
|
||
| type -p mspdb140.dll || exit 1 | ||
|
|
||
| sh -x /usr/src/build-extra/please.sh build-mingw-w64-git --only-64-bit --build-src-pkg -o artifacts HEAD && | ||
| if test -n "$GPGKEY" | ||
| then | ||
| for tar in artifacts/*.tar* | ||
| do | ||
| /usr/src/build-extra/gnupg-with-gpgkey.sh --detach-sign --no-armor $tar | ||
| done | ||
| fi && | ||
|
|
||
| b=$PWD/artifacts && | ||
| version=${{ needs.prereqs.outputs.tag_name }} && | ||
| (cd /usr/src/MINGW-packages/mingw-w64-git && | ||
| cp PKGBUILD.$version PKGBUILD && | ||
| git commit -s -m "mingw-w64-git: new version ($version)" PKGBUILD && | ||
| git bundle create "$b"/MINGW-packages.bundle origin/main..main) | ||
| - name: Publish mingw-w64-x86_64-git | ||
| uses: actions/upload-artifact@v2 | ||
| with: | ||
| name: pkg-x86_64 | ||
| path: artifacts | ||
| windows_artifacts: | ||
| runs-on: windows-latest | ||
| needs: [prereqs, windows_pkg] | ||
| strategy: | ||
| matrix: | ||
| artifact: | ||
| - name: installer | ||
| fileprefix: Git | ||
| - name: portable | ||
| fileprefix: PortableGit | ||
| fail-fast: false | ||
| steps: | ||
| - name: Download pkg-x86_64 | ||
| uses: actions/download-artifact@v2 | ||
| with: | ||
| name: pkg-x86_64 | ||
| path: pkg-x86_64 | ||
| - uses: git-for-windows/setup-git-for-windows-sdk@v1 | ||
| with: | ||
| flavor: build-installers | ||
| - name: Clone build-extra | ||
| shell: bash | ||
| run: | | ||
| git clone --single-branch -b main https://github.com/git-for-windows/build-extra /usr/src/build-extra | ||
| - name: Prepare home directory for code-signing | ||
| env: | ||
| CODESIGN_P12: ${{secrets.CODESIGN_P12}} | ||
| CODESIGN_PASS: ${{secrets.CODESIGN_PASS}} | ||
| if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != '' | ||
| shell: bash | ||
| run: | | ||
| mkdir -p home/.sig && | ||
| echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 && | ||
| echo -n "$CODESIGN_PASS" >home/.sig/codesign.pass && | ||
| git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"' | ||
| - name: Build 64-bit ${{matrix.artifact.name}} | ||
| shell: bash | ||
| run: | | ||
| set -x | ||
|
|
||
| eval /usr/src/build-extra/please.sh make_installers_from_mingw_w64_git --version=${{ needs.prereqs.outputs.tag_version }} -o artifacts --${{matrix.artifact.name}} --pkg=pkg-x86_64/mingw-w64-x86_64-git-[0-9]*.tar.xz --pkg=pkg-x86_64/mingw-w64-x86_64-git-doc-html-[0-9]*.tar.xz && | ||
| if test portable = '${{matrix.artifact.name}}' && test -n "$(git config alias.signtool)" | ||
| then | ||
| git signtool artifacts/PortableGit-*.exe | ||
| fi && | ||
| openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.exe | sed "s/.* //" >artifacts/sha-256.txt | ||
| - name: Copy package-versions and pdbs | ||
| if: matrix.artifact.name == 'installer' | ||
| shell: bash | ||
| run: | | ||
| cp /usr/src/build-extra/installer/package-versions.txt artifacts/ && | ||
|
|
||
| a=$PWD/artifacts && | ||
| p=$PWD/pkg-x86_64 && | ||
| (cd /usr/src/build-extra && | ||
| mkdir -p cached-source-packages && | ||
| cp "$p"/*-pdb* cached-source-packages/ && | ||
| GIT_CONFIG_PARAMETERS="'windows.sdk64.path='" ./please.sh bundle_pdbs --arch=x86_64 --directory="$a" installer/package-versions.txt) | ||
| - name: Publish ${{matrix.artifact.name}}-x86_64 | ||
| uses: actions/upload-artifact@v2 | ||
| with: | ||
| name: win-${{matrix.artifact.name}}-x86_64 | ||
| path: artifacts | ||
| # End build Windows installers | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a clever way to quickly check the tag matches the compiled Git version.