Skip to content

Commit

Permalink
align workflow with our workflow-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Dec 13, 2024
1 parent ce84b48 commit ffea896
Showing 1 changed file with 49 additions and 29 deletions.
78 changes: 49 additions & 29 deletions .github/workflows/release-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
# The project's folder on Arduino's download server for uploading builds
AWS_PLUGIN_TARGET: /unisense/tools/bhy-controller/
AWS_REGION: "us-east-1"
ARTIFACT_NAME: dist
ARTIFACT_PREFIX: dist-

on:
push:
Expand All @@ -25,11 +25,24 @@ jobs:
strategy:
matrix:
os:
- Windows_32bit
- Windows_64bit
- Linux_32bit
- Linux_64bit
- macOS_64bit
- task: Windows_32bit
artifact-suffix: Windows_32bit
- task: Windows_64bit
artifact-suffix: Windows_64bit
- task: Linux_32bit
artifact-suffix: Linux_32bit
- task: Linux_64bit
artifact-suffix: Linux_64bit
- task: Linux_ARMv6
artifact-suffix: Linux_ARMv6
- task: Linux_ARMv7
artifact-suffix: Linux_ARMv7
- task: Linux_ARM64
artifact-suffix: Linux_ARM64
- task: macOS_64bit
artifact-suffix: macOS_64bit
- task: macOS_ARM64
artifact-suffix: macOS_ARM64

steps:
- name: Checkout repository
Expand All @@ -39,7 +52,7 @@ jobs:

- name: Create changelog
# Avoid creating the same changelog for each os
if: matrix.os == 'Windows_32bit'
if: matrix.os.task == 'Windows_32bit'
uses: arduino/create-changelog@v1
with:
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
Expand All @@ -54,21 +67,19 @@ jobs:
version: 3.x

- name: Build
run: task dist:${{ matrix.os }}
run: task dist:${{ matrix.os.task }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ${{ env.ARTIFACT_NAME }}
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.os.artifact-suffix }}
path: ${{ env.DIST_DIR }}

notarize-macos:
name: Notarize ${{ matrix.artifact.name }}
name: Notarize ${{ matrix.build.folder-suffix }}
runs-on: macos-latest
needs: create-release-artifacts
outputs:
checksum-darwin_amd64: ${{ steps.re-package.outputs.checksum-darwin_amd64 }}
permissions:
contents: read

Expand All @@ -77,18 +88,29 @@ jobs:

strategy:
matrix:
artifact:
- name: darwin_amd64
path: "macOS_64bit.tar.gz"
build:
- artifact-suffix: macOS_64bit
folder-suffix: darwin_amd64
package-suffix: "macOS_64bit.tar.gz"
- artifact-suffix: macOS_ARM64
folder-suffix: darwin_arm64
package-suffix: "macOS_ARM64.tar.gz"

steps:
- name: Set environment variables
run: |
# See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
echo "BUILD_FOLDER=${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}" >> "$GITHUB_ENV"
TAG="${GITHUB_REF/refs\/tags\//}"
echo "PACKAGE_FILENAME=${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
path: ${{ env.DIST_DIR }}

- name: Import Code-Signing Certificates
Expand Down Expand Up @@ -125,7 +147,7 @@ jobs:
run: |
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
# See: https://github.com/Bearer/gon#configuration-file
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"]
source = ["${{ env.DIST_DIR }}/${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"]
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
sign {
Expand All @@ -148,26 +170,23 @@ jobs:
gon "${{ env.GON_CONFIG_PATH }}"
- name: Re-package binary
id: re-package
working-directory: ${{ env.DIST_DIR }}
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
run: |
# GitHub's upload/download-artifact actions don't preserve file permissions,
# so we need to add execution permission back until the action is made to do this.
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/${{ env.PROJECT_NAME }}"
TAG="${GITHUB_REF/refs\/tags\//}"
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.artifact.path }}"
tar -czvf "$PACKAGE_FILENAME" \
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
tar -czvf "${{ env.PACKAGE_FILENAME }}" \
-C "${{ env.BUILD_FOLDER }}/" "${{ env.PROJECT_NAME }}" \
-C ../../ LICENSE.txt
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
- name: Upload artifact
- name: Replace artifact with notarized build
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_DIR }}
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.build.artifact-suffix }}
overwrite: true
path: ${{ env.DIST_DIR }}/${{ env.PACKAGE_FILENAME }}

create-release:
runs-on: ubuntu-latest
Expand All @@ -181,11 +200,12 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
pattern: ${{ env.ARTIFACT_PREFIX }}*
merge-multiple: true
path: ${{ env.DIST_DIR }}

- name: Create checksum file
working-directory: ${{ env.DIST_DIR}}
working-directory: ${{ env.DIST_DIR }}
run: |
TAG="${GITHUB_REF/refs\/tags\//}"
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* > ${TAG}-checksums.txt
Expand Down

0 comments on commit ffea896

Please sign in to comment.