Skip to content

Commit c20ced1

Browse files
committed
simplify and clean up action
1 parent 4ca9454 commit c20ced1

File tree

1 file changed

+9
-66
lines changed

1 file changed

+9
-66
lines changed

action.yml

Lines changed: 9 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ inputs:
55
description: 'Artifact ID for the Zipfile to download. Zipfile should contain firmware.bin, bootloader.bin, partition-table.bin, and flasher_args.json. May optionally contain filesystem binaries and associated -flash_args files.'
66
required: true
77
programmer-name:
8-
description: 'Base name of the programmer executable. Will have version tag (e.g. v1.0.0) and OS suffix (e.g. windows, linux, macos) appended.'
8+
description: 'Base name of the programmer executable. Will have version tag (e.g. v1.0.0 or commit hash if no tags) and OS suffix (e.g. windows, linux, macos) appended.'
99
required: false
1010
default: 'programmer'
11-
version-str:
12-
description: 'Version string to append to the programmer executable. If not provided, will be set to the version of the parent repo if this action is run as part of a release. Otherwise the default will be set to "unknown".'
13-
required: false
14-
default: ${{ github.event.release && github.event.release.tag_name || 'unknown' }}
1511
outputs:
1612
artifact-name:
1713
description: "Name of the programmer artifact that was packaged and uploaded"
@@ -26,49 +22,18 @@ runs:
2622
echo "::error title=⛔ error hint::Support Linux, Windows, and macOS Only"
2723
exit 1
2824
29-
# It is a release, so we can get the version from the release tag
30-
- name: Set the version string if this was run as part of a release
31-
if: ${{ github.event.release && github.event.action == 'published' }}
32-
shell: bash
33-
run: |
34-
# Get the version of the parent repo
35-
version=${{ github.event.release.tag_name }}
36-
echo "Version: ${version}"
37-
# Set the version as an output variable
38-
echo "version_str=$version" >> $GITHUB_ENV
39-
40-
# It's not a release and the version is NOT 'unknown', which means the user
41-
# provided a specific version, so just set the version string accordingly
42-
- name: Otherwise use git to get the version
43-
if: ${{ !(github.event.release && github.event.action == 'published') &&
44-
inputs.version-str != 'unknown' }}
45-
shell: bash
46-
run: |
47-
# Get the version of the parent repo
48-
version=${{ inputs.version-str }}
49-
echo "Version: ${version}"
50-
# Set the version as an output variable
51-
echo "version_str=$version" >> $GITHUB_ENV
52-
53-
# It's not a release and the version is 'unknown', so we need to get the
54-
# version from the parent repo
55-
- name: Otherwise clone the parent repo and get the version
56-
if: ${{ !(github.event.release && github.event.action == 'published') &&
57-
inputs.version-str == 'unknown' }}
25+
- name: Clone the parent repo (to get the version)
5826
uses: actions/checkout@v4
5927
with:
6028
fetch-depth: 0
61-
- name: Otherwise use git to get the version
62-
if: ${{ !(github.event.release && github.event.action == 'published') &&
63-
inputs.version-str == 'unknown' }}
29+
30+
- name: Get the version
6431
shell: bash
6532
run: |
6633
echo "Trying to get the version from the parent repo"
67-
# print out all files here so we know where we are...
68-
find .
6934
# Get the version of the parent repo
70-
version=$(git describe --tags --dirty)
71-
echo "Version: ${version}"
35+
version=$(git describe --tags --dirty || git rev-parse --short HEAD)
36+
echo "Got version: ${version}"
7237
# Set the version as an output variable
7338
echo "version_str=$version" >> $GITHUB_ENV
7439
@@ -106,7 +71,6 @@ runs:
10671
working-directory: ${{ github.action_path }}
10772
shell: pwsh
10873
run: |
109-
# change the build-artifacts directory to the current working directory
11074
# setup the python environment
11175
${{ steps.id_python_310.outputs.python-path }} -m pip install -r requirements.txt
11276
# we need to clone v4.7.0 of esptool into the repo to ensure all of its data is properly packaged
@@ -118,41 +82,20 @@ runs:
11882
mv dist/programmer.exe ${artifact_name}
11983
"artifactName=${artifact_name}" | Out-File -FilePath $env:GITHUB_ENV -Append
12084
121-
# Build if Linux
122-
- name: PyInstaller
123-
if: ${{ runner.os == 'Linux'}}
124-
working-directory: ${{ github.action_path }}
125-
shell: bash
126-
run: |
127-
# setup the python environment
128-
${{ steps.id_python_310.outputs.python-path }} -m pip install -r requirements.txt
129-
# we need to clone v4.7.0 of esptool into the repo to ensure all of its data is properly packaged
130-
git clone --depth 1 --branch v4.7.0 https://github.com/espressif/esptool
131-
# now build the installer
132-
${{ steps.id_python_310.outputs.python-path }} -m PyInstaller --clean programmer.spec
133-
# now actually make the artifact
134-
artifact_name="${{ inputs.programmer-name }}_${{ env.version_str }}_linux.bin"
135-
mv dist/programmer $artifact_name
136-
echo "artifactName=$artifact_name" >> "$GITHUB_ENV"
137-
138-
# Build if MacOS
85+
# Build if Linux or macOS
13986
- name: PyInstaller
140-
if: ${{ runner.os == 'macOS' }}
87+
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
14188
working-directory: ${{ github.action_path }}
14289
shell: bash
14390
run: |
144-
# we don't control the name of the unpacked archive (folder) that's
145-
# within build/ so simply move everything within that subfolder into
146-
# build/
147-
find build -maxdepth 2 -mindepth 2 -exec mv {} build/. \;
14891
# setup the python environment
14992
${{ steps.id_python_310.outputs.python-path }} -m pip install -r requirements.txt
15093
# we need to clone v4.7.0 of esptool into the repo to ensure all of its data is properly packaged
15194
git clone --depth 1 --branch v4.7.0 https://github.com/espressif/esptool
15295
# now build the installer
15396
${{ steps.id_python_310.outputs.python-path }} -m PyInstaller --clean programmer.spec
15497
# now actually make the artifact
155-
artifact_name="${{ inputs.programmer-name }}_${{ env.version_str }}_macos.bin"
98+
artifact_name="${{ inputs.programmer-name }}_${{ env.version_str }}_${{ runner.os.lower() }}.bin"
15699
mv dist/programmer $artifact_name
157100
echo "artifactName=$artifact_name" >> "$GITHUB_ENV"
158101

0 commit comments

Comments
 (0)