| 1 |
on: [push, pull_request] |
| 2 |
name: Build binaries |
| 3 |
jobs: |
| 4 |
build-macos: |
| 5 |
strategy: |
| 6 |
matrix: |
| 7 |
go-version: ["1.17"] |
| 8 |
os: [macos-latest] |
| 9 |
runs-on: ${{ matrix.os }} |
| 10 |
env: |
| 11 |
CGO_ENABLED: 1 |
| 12 |
steps: |
| 13 |
- name: Install Go |
| 14 |
uses: actions/setup-go@v2 |
| 15 |
with: |
| 16 |
go-version: ${{ matrix.go-version }} |
| 17 |
- name: Checkout code |
| 18 |
uses: actions/checkout@v2 |
| 19 |
with: |
| 20 |
|
| 21 |
fetch-depth: 0 |
| 22 |
- name: Calculate git version and add it to the environment |
| 23 |
shell: bash |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
run: | |
| 28 |
echo "GIT_VERSION=$(git describe --tags)" >> $GITHUB_ENV |
| 29 |
- name: Build macos binary |
| 30 |
run: | |
| 31 |
go build -o build/macos/smimesign -ldflags "-X main.versionString=${{ env.GIT_VERSION }}" . |
| 32 |
- name: Tar the macOS binary |
| 33 |
run: | |
| 34 |
# We cd so that the binary ends up in the top level of the tar. |
| 35 |
cd build/macos && tar -czvf smimesign-macos-${{ env.GIT_VERSION }}.tgz smimesign |
| 36 |
- name: Upload build folder to the action |
| 37 |
uses: actions/upload-artifact@v2 |
| 38 |
with: |
| 39 |
|
| 40 |
|
| 41 |
name: build |
| 42 |
path: build/ |
| 43 |
- name: Upload macOS files to the release |
| 44 |
|
| 45 |
uses: softprops/action-gh-release@2d72d869af3bf23602f9593a1e3fd739b80ac1eb |
| 46 |
if: startsWith(github.ref, 'refs/tags/v') |
| 47 |
with: |
| 48 |
files: | |
| 49 |
build/macOS/smimesign-macos-${{ env.GIT_VERSION }}.tgz |
| 50 |
build-windows: |
| 51 |
strategy: |
| 52 |
matrix: |
| 53 |
go-version: ["1.17"] |
| 54 |
os: [windows-latest] |
| 55 |
runs-on: ${{ matrix.os }} |
| 56 |
env: |
| 57 |
CGO_ENABLED: 1 |
| 58 |
steps: |
| 59 |
- name: Install Go |
| 60 |
uses: actions/setup-go@v2 |
| 61 |
with: |
| 62 |
go-version: ${{ matrix.go-version }} |
| 63 |
- name: Checkout code |
| 64 |
uses: actions/checkout@v2 |
| 65 |
with: |
| 66 |
|
| 67 |
fetch-depth: 0 |
| 68 |
- name: Calculate git version and add it to the environment |
| 69 |
shell: bash |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
run: | |
| 74 |
echo "GIT_VERSION=$(git describe --tags)" >> $GITHUB_ENV |
| 75 |
- name: Calculate bare git version and add it to the environment |
| 76 |
|
| 77 |
shell: bash |
| 78 |
run: | |
| 79 |
if [[ "${GIT_VERSION}" =~ ^v([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)(-[A-za-z0-9-]*)? ]] |
| 80 |
then |
| 81 |
echo "BARE_GIT_VERSION=${BASH_REMATCH[1]}" >> $GITHUB_ENV |
| 82 |
else |
| 83 |
echo "Could not calculate the bare git version (e.g. `v1.1.0-rc1-28-g8a54734` -> `1.1.0`) for: ${GIT_VERSION}" |
| 84 |
exit 1 |
| 85 |
fi |
| 86 |
- name: Build amd64 |
| 87 |
shell: bash |
| 88 |
run: | |
| 89 |
GOARCH=amd64 go build -o "build/amd64/smimesign.exe" -ldflags "-X main.versionString=${{ env.GIT_VERSION }}" |
| 90 |
- name: Switch MinGW to x86 |
| 91 |
|
| 92 |
uses: egor-tensin/setup-mingw@f3c5d799aadf8fa230ac67a422b01dd085bbc96b |
| 93 |
with: |
| 94 |
platform: x86 |
| 95 |
- name: Build 386 |
| 96 |
shell: bash |
| 97 |
run: | |
| 98 |
GOARCH=386 go build -o "build/386/smimesign.exe" -ldflags "-X main.versionString=${{ env.GIT_VERSION }}" . |
| 99 |
- name: Sign amd64 and 386 |
| 100 |
if: startsWith(github.ref, 'refs/tags/v') |
| 101 |
run: | |
| 102 |
.\windows-installer\signtool.exe sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /p ${{ secrets.PFX_PASSWORD }} /f windows-installer\codesign.pfx build/amd64/smimesign.exe |
| 103 |
.\windows-installer\signtool.exe sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /p ${{ secrets.PFX_PASSWORD }} /f windows-installer\codesign.pfx build/386/smimesign.exe |
| 104 |
- name: Create installer |
| 105 |
shell: bash |
| 106 |
run: | |
| 107 |
GIT_VERSION=${{ env.GIT_VERSION }} BARE_GIT_VERSION=${{ env.BARE_GIT_VERSION }} iscc windows-installer/inno-setup-smimesign-installer.iss |
| 108 |
- name: Sign installer |
| 109 |
if: startsWith(github.ref, 'refs/tags/v') |
| 110 |
run: | |
| 111 |
.\windows-installer\signtool.exe sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /p ${{ secrets.PFX_PASSWORD }} /f windows-installer\codesign.pfx build\installer\smimesign-windows-*.exe |
| 112 |
- name: Create zips for release upload |
| 113 |
run: | |
| 114 |
Compress-Archive -Path build\amd64\smimesign.exe -DestinationPath build\amd64\smimesign.zip |
| 115 |
Compress-Archive -Path build\386\smimesign.exe -DestinationPath build\386\smimesign.zip |
| 116 |
- name: Rename zips for release upload |
| 117 |
shell: bash |
| 118 |
run: | |
| 119 |
mv build/amd64/smimesign.zip build/amd64/smimesign-windows-amd64-${{ env.GIT_VERSION }}.zip |
| 120 |
mv build/386/smimesign.zip build/386/smimesign-windows-386-${{ env.GIT_VERSION }}.zip |
| 121 |
- name: Upload build folder to the action |
| 122 |
uses: actions/upload-artifact@v2 |
| 123 |
with: |
| 124 |
|
| 125 |
|
| 126 |
name: build |
| 127 |
path: build/ |
| 128 |
- name: Upload Windows files to the release |
| 129 |
|
| 130 |
uses: softprops/action-gh-release@2d72d869af3bf23602f9593a1e3fd739b80ac1eb |
| 131 |
if: startsWith(github.ref, 'refs/tags/v') |
| 132 |
with: |
| 133 |
files: | |
| 134 |
build/amd64/smimesign-windows-amd64-${{ env.GIT_VERSION }}.zip |
| 135 |
build/386/smimesign-windows-386-${{ env.GIT_VERSION }}.zip |
| 136 |
build/installer/smimesign-windows-*.exe |