Skip to content

Sync build assets from templates #164

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 3 commits into from
Mar 8, 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
2 changes: 1 addition & 1 deletion .github/workflows/check-go-dependencies-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
RESULT="false"
fi

echo "::set-output name=result::$RESULT"
echo "result=$RESULT" >> $GITHUB_OUTPUT

check-cache:
needs: run-determination
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-notarization-certificates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
echo "Certificate expiration date: $EXPIRATION_DATE"
echo "Days remaining before expiration: $DAYS_BEFORE_EXPIRATION"

echo "::set-output name=days::$DAYS_BEFORE_EXPIRATION"
echo "days=$DAYS_BEFORE_EXPIRATION" >> $GITHUB_OUTPUT

- name: Check if expiration notification period has been reached
id: check-expiration
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ jobs:
id: determination
run: |
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
if [[ "${{ github.event_name }}" == "push" || ( "${{ github.event_name }}" == "create" && "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX ) ]]; then
if [[
"${{ github.event_name }}" == "push" ||
(
"${{ github.event_name }}" == "create" &&
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
)
]]; then
RESULT="true"
else
RESULT="false"
fi

echo "::set-output name=result::$RESULT"
echo "result=$RESULT" >> $GITHUB_OUTPUT

publish:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,15 +83,20 @@ jobs:

- name: Determine versioning parameters
id: determine-versioning
run: echo "::set-output name=data::$(poetry run python docs/siteversion/siteversion.py)"
run: echo "data=$(poetry run python docs/siteversion/siteversion.py)" >> $GITHUB_OUTPUT

- name: Publish documentation
if: fromJson(steps.determine-versioning.outputs.data).version != null
run: |
# Publishing implies creating a git commit on the gh-pages branch, we let @ArduinoBot own these commits.
git config --global user.email "[email protected]"
git config --global user.name "ArduinoBot"
git fetch --no-tags --prune --depth=1 origin +refs/heads/gh-pages:refs/remotes/origin/gh-pages
git fetch \
--no-tags \
--prune \
--depth=1 \
origin \
+refs/heads/gh-pages:refs/remotes/origin/gh-pages
poetry run mike deploy \
--update-aliases \
--push \
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/generate-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ jobs:
# disable gpg pass prompt
# https://stackoverflow.com/questions/49072403/suppress-the-passphrase-prompt-in-gpg-command
- name: sign the json
run: gpg --pinentry-mode=loopback --passphrase "${{ secrets.PASSPHRASE }}" --output boards/module_firmware_index.json.sig --detach-sign boards/module_firmware_index.json
run: |
gpg \
--pinentry-mode=loopback \
--passphrase "${{ secrets.PASSPHRASE }}" \
--output boards/module_firmware_index.json.sig \
--detach-sign boards/module_firmware_index.json

- name: create the gzip
run: gzip --keep boards/module_firmware_index.json
Expand Down
140 changes: 82 additions & 58 deletions .github/workflows/publish-go-tester-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ on:
env:
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
GO_VERSION: "1.18"
# As defined by the Taskfile's PROJECT_NAME variable
PROJECT_NAME: arduino-fwuploader
# As defined by the Taskfile's DIST_DIR variable
DIST_DIR: dist
BUILDS_ARTIFACT: build-artifacts

jobs:
run-determination:
Expand All @@ -40,10 +41,12 @@ jobs:
id: determination
run: |
RELEASE_BRANCH_REGEX="refs/heads/[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.event_name }}" != "create" ||
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX) &&
! "${{ github.ref }}" =~ $TAG_REGEX
]]; then
# Run the other jobs.
RESULT="true"
Expand All @@ -52,12 +55,61 @@ jobs:
RESULT="false"
fi

echo "::set-output name=result::$RESULT"
echo "result=$RESULT" >> $GITHUB_OUTPUT

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 }}-"

echo "prefix=$PACKAGE_NAME_PREFIX" >> $GITHUB_OUTPUT

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

strategy:
matrix:
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
- task: Linux_64bit
path: "*Linux_64bit.tar.gz"
name: Linux_X86-64
- task: Linux_ARMv6
path: "*Linux_ARMv6.tar.gz"
name: Linux_ARMv6
- task: Linux_ARMv7
path: "*Linux_ARMv7.tar.gz"
name: Linux_ARMv7
- task: Linux_ARM64
path: "*Linux_ARM64.tar.gz"
name: Linux_ARM64
- task: macOS_64bit
path: "*macOS_64bit.tar.gz"
name: macOS_64
- task: macOS_ARM64
path: "*macOS_ARM64.tar.gz"
name: macOS_ARM64

steps:
- name: Checkout repository
Expand All @@ -76,69 +128,41 @@ jobs:

- name: Build
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 }}-"
PACKAGE_NAME_PREFIX=${{ needs.package-name-prefix.outputs.prefix }}
export PACKAGE_NAME_PREFIX
task dist:all
task dist:${{ matrix.os.task }}

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

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

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

steps:
- name: Download combined builds artifact
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.BUILDS_ARTIFACT }}
path: ${{ env.BUILDS_ARTIFACT }}

- name: Upload individual build artifact
- 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:
path: ${{ env.BUILDS_ARTIFACT }}/${{ matrix.artifact.path }}
name: ${{ matrix.artifact.name }}

clean:
needs: artifacts
runs-on: ubuntu-latest

steps:
- name: Remove unneeded combined builds artifact
uses: geekyeggo/delete-artifact@v2
with:
name: ${{ env.BUILDS_ARTIFACT }}
path: ./*checksums.txt
name: checksums
49 changes: 26 additions & 23 deletions .github/workflows/release-go-crosscompile-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,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: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
Expand All @@ -47,7 +62,7 @@ jobs:
version: 3.x

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

- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand All @@ -60,9 +75,6 @@ jobs:
name: Notarize ${{ matrix.artifact.name }}
runs-on: macos-latest
needs: create-release-artifacts
outputs:
checksum-darwin_amd64: ${{ steps.re-package.outputs.checksum-darwin_amd64 }}
checksum-darwin_arm64: ${{ steps.re-package.outputs.checksum-darwin_arm64 }}

env:
GON_CONFIG_PATH: gon.config.hcl
Expand All @@ -89,7 +101,8 @@ jobs:
env:
KEYCHAIN: "sign.keychain"
INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12"
KEYCHAIN_PASSWORD: keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret
# Arbitrary password for a keychain that exists only for the duration of the job, so not secret
KEYCHAIN_PASSWORD: keychainpassword
run: |
echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > "${{ env.INSTALLER_CERT_MAC_PATH }}"
security create-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
Expand Down Expand Up @@ -139,14 +152,10 @@ jobs:
run: |
gon "${{ env.GON_CONFIG_PATH }}"

- name: Re-package binary and output checksum
- name: Re-package binary
id: re-package
working-directory: ${{ env.DIST_DIR }}
# This step performs the following:
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
# 2. Recalculate package checksum
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
# (it cannot be done there because of workflow job parallelization)
# 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.
Expand All @@ -156,11 +165,9 @@ jobs:
tar -czvf "$PACKAGE_FILENAME" \
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
-C ../../ LICENSE.txt
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"

- name: Upload artifacts
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
Expand Down Expand Up @@ -192,15 +199,11 @@ jobs:
# would be calculated since the binary is modified during notarization
run: task dist:generate-index-data

- name: Update checksum
- name: Create checksum file
working-directory: ${{ env.DIST_DIR}}
run: |
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
for checksum_line in "${checksum_lines[@]}"
do
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
done
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
Expand All @@ -209,7 +212,7 @@ jobs:
run: |
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 "::set-output name=IS_PRE::true"; fi
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
2 changes: 1 addition & 1 deletion .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
run: |
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
# configuration.
echo "::set-output name=flag::--dry-run"
echo "flag=--dry-run" >> $GITHUB_OUTPUT

- name: Checkout repository
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-go-integration-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
RESULT="false"
fi

echo "::set-output name=result::$RESULT"
echo "result=$RESULT" >> $GITHUB_OUTPUT

test:
needs: run-determination
Expand Down
Loading