Skip to content
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

fix(ci): release builds #2219

Merged
merged 50 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7bf38a5
fixes
Arqu Apr 22, 2024
ee8aef6
fixes
Arqu Apr 22, 2024
b750a72
fixes
Arqu Apr 22, 2024
4824863
test
Arqu Apr 22, 2024
f8805e0
test
Arqu Apr 22, 2024
afc7902
test
Arqu Apr 22, 2024
66352d4
test
Arqu Apr 22, 2024
c7a6c61
test
Arqu Apr 22, 2024
8f2192d
test
Arqu Apr 22, 2024
2748134
test
Arqu Apr 22, 2024
5c6e777
test
Arqu Apr 22, 2024
501c983
test
Arqu Apr 23, 2024
7511616
test
Arqu Apr 23, 2024
74740b0
test
Arqu Apr 24, 2024
e6943dc
test
Arqu Apr 24, 2024
8139bb0
test
Arqu Apr 24, 2024
63fa65f
test
Arqu Apr 24, 2024
b764499
test
Arqu Apr 24, 2024
a9fa815
test
Arqu Apr 24, 2024
73c59b9
test
Arqu Apr 24, 2024
13f5821
test
Arqu Apr 24, 2024
ced3e3a
test
Arqu Apr 24, 2024
269d26e
test
Arqu Apr 24, 2024
785d86d
test
Arqu Apr 24, 2024
8b06289
test
Arqu Apr 24, 2024
627c5bc
test
Arqu Apr 24, 2024
b451cf2
test
Arqu Apr 24, 2024
a072084
test
Arqu Apr 25, 2024
bb36995
test
Arqu Apr 25, 2024
b28f041
test
Arqu Apr 25, 2024
8e5eb0a
test
Arqu Apr 25, 2024
6c8b7b1
test
Arqu Apr 25, 2024
37a6e9e
test
Arqu Apr 25, 2024
f272978
test
Arqu Apr 25, 2024
173e21d
test
Arqu Apr 25, 2024
e74001f
test
Arqu Apr 25, 2024
105449f
test
Arqu Apr 25, 2024
6647bb1
test
Arqu Apr 25, 2024
c0ef07d
test
Arqu Apr 25, 2024
4c99f85
test
Arqu Apr 25, 2024
54c34ef
test
Arqu Apr 25, 2024
77e5a4e
test
Arqu Apr 25, 2024
d782e4f
test
Arqu Apr 25, 2024
4fa1779
test
Arqu Apr 26, 2024
c267ba0
test
Arqu Apr 26, 2024
4087541
test
Arqu Apr 26, 2024
f2ef68f
test
Arqu Apr 26, 2024
bfaf0d0
test
Arqu Apr 29, 2024
1cb89e8
cleanup
Arqu Apr 29, 2024
da530a4
Merge branch 'main' into arqu/release_windows
Arqu Apr 29, 2024
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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Set line endings to LF, even on Windows. Otherwise, execution within CI fails.
# See https://help.github.com/articles/dealing-with-line-endings/
*.sh text eol=lf
72 changes: 44 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ env:
MSRV: "1.75"
SCCACHE_CACHE_SIZE: "50G"
BIN_NAMES: "iroh,iroh-relay,iroh-dns-server"
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given you have a whole script a little lower to set this in several ways I assume this is a leftover of an earlier version and should be removed?


jobs:
create-release:
Expand All @@ -39,13 +40,18 @@ jobs:
upload_url: ${{ steps.release.outputs.upload_url }}
release_version: ${{ env.RELEASE_VERSION }}
steps:
- name: Get the release version from the tag (push)
- name: Get the release version from the tag or input
shell: bash
if: env.RELEASE_VERSION == '' && github.event_name == 'push'
if: env.RELEASE_VERSION == ''
run: |
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.RELEASE_VERSION }}"
if "${{ github.event.inputs.release_version }}" != ""; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
echo "version is: ${{ env.RELEASE_VERSION }}"
else
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.RELEASE_VERSION }}"
fi
- name: Checkout repository
uses: actions/checkout@v4
with:
Expand All @@ -57,6 +63,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ env.RELEASE_VERSION || github.event.inputs.release_version}}
release_name: ${{ env.RELEASE_VERSION || github.event.inputs.release_version }}

Expand Down Expand Up @@ -138,13 +145,18 @@ jobs:
rustup target add ${{ matrix.cargo_targets }}

- name: build release
if: matrix.os != 'windows-latest'
shell: bash
run: |
if [ "${{ matrix.name }}" = "ubuntu-arm-latest" ]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc
export CC=aarch64-linux-gnu-gcc
fi
cargo build --profile optimized-release --all-features --target ${{ matrix.cargo_targets }}

- name: build release
if: matrix.os == 'windows-latest'
run: cargo build --profile optimized-release --all-features --target ${{ matrix.cargo_targets }}
Comment on lines +156 to +159
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why windows gets its own section here, the cargo command is exactly the same as the unix version above?


- name: attach artifacts
if: matrix.os != 'windows-latest'
Expand Down Expand Up @@ -204,36 +216,40 @@ jobs:
aws s3 cp ./target/${{ matrix.cargo_targets }}/optimized-release/iroh-dns-server s3://vorc/iroh-dns-server-${RELEASE_OS}-${RELEASE_ARCH}-latest --no-progress

- name: Build archives
if: matrix.os != 'windows-latest'
shell: bash
run: |
IFS=',' read -ra BIN_NAMES <<< "${{ env.BIN_NAMES }}"
ASSETS=""
for BIN_NAME in "${BIN_NAMES[@]}"; do
staging="$BIN_NAME-${{ needs.create-release.outputs.release_version }}-${{ matrix.cargo_targets }}"
mkdir -p "$staging"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp "target/${{ matrix.cargo_targets }}/optimized-release/$BIN_NAME.exe" "$staging/"
cd "$staging"
7z a "../$staging.zip" .
ASSETS+="$staging.zip,"
else
cp "target/${{ matrix.cargo_targets }}/optimized-release/$BIN_NAME" "$staging/"
tar czf "$staging.tar.gz" -C "$staging" .
ASSETS+="$staging.tar.gz,"
fi
cp "target/${{ matrix.cargo_targets }}/optimized-release/$BIN_NAME" "$staging/"
tar czf "$staging.tar.gz" -C "$staging" .
ASSETS+="$staging.tar.gz,"
done
echo "ASSET=${ASSETS::-1}" >> $GITHUB_ENV
echo "ASSET=$(echo $ASSETS | sed 's/,$//')" >> $GITHUB_ENV

- name: Upload release archives
if: github.event.inputs.upload_artifacts == 'true' || github.event_name == 'push'
- name: Build archives (windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
IFS=',' read -ra ASSETS <<< "${{ env.ASSET }}"
for ASSET in "${ASSETS[@]}"; do
ASSET_NAME=$(basename $ASSET)
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type application/octet-stream)" \
--data-binary @"$ASSET" \
"${{ needs.create-release.outputs.upload_url }}?name=$ASSET_NAME"
done

$BIN_NAMES = "${{ env.BIN_NAMES }}".Split(',')
$ASSETS = @()
foreach ($BIN_NAME in $BIN_NAMES) {
$staging = "$BIN_NAME-${{ needs.create-release.outputs.release_version }}-${{ matrix.cargo_targets }}"
New-Item -ItemType Directory -Force -Path "$staging"
Copy-Item -Path "target/${{ matrix.cargo_targets }}/optimized-release/$BIN_NAME.exe" -Destination "$staging/"
Set-Location -Path "$staging"
Compress-Archive -Path * -DestinationPath "../$staging.zip"
$ASSETS += "$staging.zip"
Set-Location -Path ..
}
$ASSETS = $ASSETS -join ','
Add-Content -Path $env:GITHUB_ENV -Value "ASSET=$ASSETS"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in general a bit careful about using actions from a branch rather than a tag, which can still be moving like .e.g. v1. But the repo doesn't seem to have any tags.

- uses: n0-computer/actions-upload-release-asset@main
if: (github.event.inputs.upload_artifacts == 'true' || github.event_name == 'push')
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ env.ASSET }}
Loading