Skip to content

Update release workflows to add macOS arm64 support #57

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 1 commit into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 101 additions & 51 deletions .github/workflows/publish-go-tester-task.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md
name: Publish Tester Build

# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
on:
create:
push:
paths:
- ".github/workflows/publish-go-tester-task.ya?ml"
Expand All @@ -23,89 +24,138 @@ on:
repository_dispatch:

env:
# As defined by the Taskfile's PROJECT_NAME variable
PROJECT_NAME: serial-discovery
# As defined by the Taskfile's DIST_DIR variable
DIST_DIR: dist
BUILDS_ARTIFACT: build-artifacts

jobs:
build:
run-determination:
runs-on: ubuntu-latest

outputs:
result: ${{ steps.determination.outputs.result }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Determine if the rest of the workflow should run
id: determination
run: |
RELEASE_BRANCH_REGEX="refs/heads/v[0-9]+.[0-9]+.x"
TAG_REGEX="refs/tags/.*"
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
if [[
("${{ github.event_name }}" != "create" ||
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX) &&
! "${{ github.ref }}" =~ $TAG_REGEX
]]; then
# Run the other jobs.
RESULT="true"
else
# There is no need to run the other jobs.
RESULT="false"
fi

- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
echo "result=$RESULT" >> $GITHUB_OUTPUT

- name: Build
package-name-prefix:
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest
outputs:
prefix: ${{ steps.calculation.outputs.prefix }}
steps:
- name: package name prefix calculation
id: calculation
run: |
PACKAGE_NAME_PREFIX="test"
if [ "${{ github.event_name }}" = "pull_request" ]; then
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}"
fi
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-"
export PACKAGE_NAME_PREFIX
task dist:all

# Transfer builds to artifacts job
- name: Upload combined builds artifact
uses: actions/upload-artifact@v3
with:
path: ${{ env.DIST_DIR }}
name: ${{ env.BUILDS_ARTIFACT }}
echo "prefix=$PACKAGE_NAME_PREFIX" >> $GITHUB_OUTPUT

artifacts:
name: ${{ matrix.artifact.name }} artifact
needs: build
build:
needs: package-name-prefix
name: Build ${{ matrix.os.name }}
runs-on: ubuntu-latest

strategy:
matrix:
artifact:
- path: "*checksums.txt"
name: checksums
- path: "*Linux_32bit.tar.gz"
os:
- task: Windows_32bit
path: "*Windows_32bit.zip"
name: Windows_X86-32
- task: Windows_64bit
path: "*Windows_64bit.zip"
name: Windows_X86-64
- task: Linux_32bit
path: "*Linux_32bit.tar.gz"
name: Linux_X86-32
- path: "*Linux_64bit.tar.gz"
- task: Linux_64bit
path: "*Linux_64bit.tar.gz"
name: Linux_X86-64
- path: "*Linux_ARM64.tar.gz"
name: Linux_ARM64
- path: "*Linux_ARMv6.tar.gz"
- task: Linux_ARMv6
path: "*Linux_ARMv6.tar.gz"
name: Linux_ARMv6
- path: "*Linux_ARMv7.tar.gz"
- task: Linux_ARMv7
path: "*Linux_ARMv7.tar.gz"
name: Linux_ARMv7
- path: "*macOS_64bit.tar.gz"
- task: Linux_ARM64
path: "*Linux_ARM64.tar.gz"
name: Linux_ARM64
- task: macOS_64bit
path: "*macOS_64bit.tar.gz"
name: macOS_64
- path: "*Windows_32bit.zip"
name: Windows_X86-32
- path: "*Windows_64bit.zip"
name: Windows_X86-64
- task: macOS_ARM64
path: "*macOS_ARM64.tar.gz"
name: macOS_ARM64

steps:
- name: Download combined builds artifact
uses: actions/download-artifact@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Task
uses: arduino/setup-task@v1
with:
name: ${{ env.BUILDS_ARTIFACT }}
path: ${{ env.BUILDS_ARTIFACT }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Build
run: |
PACKAGE_NAME_PREFIX=${{ needs.package-name-prefix.outputs.prefix }}
export PACKAGE_NAME_PREFIX
task dist:${{ matrix.os.task }}

- name: Upload individual build artifact
# Transfer builds to artifacts job
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
path: ${{ env.BUILDS_ARTIFACT }}/${{ matrix.artifact.path }}
name: ${{ matrix.artifact.name }}
path: ${{ env.DIST_DIR }}/${{ matrix.os.path }}
name: ${{ matrix.os.name }}

clean:
needs: artifacts
checksums:
needs:
- build
- package-name-prefix
runs-on: ubuntu-latest

steps:
- name: Remove unneeded combined builds artifact
uses: geekyeggo/delete-artifact@v2
- name: Download build artifacts
uses: actions/download-artifact@v3

- name: Create checksum file
run: |
TAG="${{ needs.package-name-prefix.outputs.prefix }}git-snapshot"
declare -a artifacts=($(ls -d */))
for artifact in ${artifacts[@]}
do
cd $artifact
checksum=$(sha256sum ${{ env.PROJECT_NAME }}_${TAG}*)
cd ..
echo $checksum >> ${TAG}-checksums.txt
done

- name: Upload checksum artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.BUILDS_ARTIFACT }}
path: ./*checksums.txt
name: checksums
54 changes: 50 additions & 4 deletions .github/workflows/release-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,28 @@ jobs:
create-release-artifacts:
runs-on: ubuntu-latest

strategy:
matrix:
os:
- Windows_32bit
- Windows_64bit
- Linux_32bit
- Linux_64bit
- Linux_ARMv6
- Linux_ARMv7
- Linux_ARM64
- macOS_64bit
- macOS_ARM64

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

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

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

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

create-release:
runs-on: ubuntu-latest
needs: create-release-artifacts

steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_DIR }}

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

- name: Identify Prerelease
# This is a workaround while waiting for create-release action
# to implement auto pre-release based on tag
id: prerelease
run: |
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip
unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
unzip -p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver >/tmp/semver && chmod +x /tmp/semver
if [[
"$(
/tmp/semver get prerel \
"${GITHUB_REF/refs\/tags\//}"
)"
]]; then
echo "IS_PRE=true" >> $GITHUB_OUTPUT
fi

- name: Create Github Release and upload artifacts
uses: ncipollo/release-action@v1
Expand Down
Loading