Skip to content

Commit

Permalink
Upgrade release actions (#165)
Browse files Browse the repository at this point in the history
* Migrate create-release action

* Migrate to new action for uploading assets to the GitHub release

* Further simplify everything by removing version number from archive filenames
  • Loading branch information
sgb-io authored Sep 23, 2024
1 parent a4e0f9a commit fa09720
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 132 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ jobs:
- name: Create tarballs and move binaries
run: |
tar czvf x86_64-apple-darwin.tar.gz -C target/x86_64-apple-darwin/release fta
tar czvf aarch64-apple-darwin.tar.gz -C target/aarch64-apple-darwin/release fta
tar czvf fta-x86_64-apple-darwin.tar.gz -C target/x86_64-apple-darwin/release fta
tar czvf fta-aarch64-apple-darwin.tar.gz -C target/aarch64-apple-darwin/release fta
- name: Upload binaries as artifacts
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -106,8 +106,8 @@ jobs:
- name: Create zipfiles and move binaries
shell: pwsh
run: |
Compress-Archive -Path target/x86_64-pc-windows-msvc/release/fta.exe -DestinationPath x86_64-pc-windows-msvc.zip
Compress-Archive -Path target/aarch64-pc-windows-msvc/release/fta.exe -DestinationPath aarch64-pc-windows-msvc.zip
Compress-Archive -Path target/x86_64-pc-windows-msvc/release/fta.exe -DestinationPath fta-x86_64-pc-windows-msvc.zip
Compress-Archive -Path target/aarch64-pc-windows-msvc/release/fta.exe -DestinationPath fta-aarch64-pc-windows-msvc.zip
- name: Upload binaries as artifacts
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
echo "Building for $TARGET"
cargo build --release --target="$TARGET"
chmod +x target/${TARGET}/release/fta
tar czf "${TARGET}.tar.gz" -C "./target/${TARGET}/release/" fta
tar czf "fta-${TARGET}.tar.gz" -C "./target/${TARGET}/release/" fta
done
- name: Upload binaries as artifacts
Expand Down
137 changes: 23 additions & 114 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,145 +14,54 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get version
id: get_version
run: |
VERSION=$(grep '^version =' crates/fta/Cargo.toml | sed 's/^version = "\(.*\)"/\1/')
echo "Version: $VERSION"
echo "FTA_VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Build binaries
uses: ./.github/workflows/build.yml

- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: v${{ steps.get_version.outputs.FTA_VERSION }}
name: v${{ steps.get_version.outputs.FTA_VERSION }}
draft: true
prerelease: false
outputs:
version_name: ${{ steps.get_version.outputs.FTA_VERSION }}
upload_url: ${{ steps.create_release.outputs.upload_url }}

build_binaries:
uses: ./.github/workflows/build.yml

upload_assets_macos:
needs: [create_github_release, build_binaries]
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- name: Download macOS artifact
- name: Download macOS artifacts
uses: actions/download-artifact@v4
with:
name: macos-binaries

- name: Upload macOS x86 tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_github_release.outputs.upload_url }}
asset_path: ./x86_64-apple-darwin.tar.gz
asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-x86_64-apple-darwin.tar.gz
asset_content_type: application/gzip

- name: Upload macOS silicon tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_github_release.outputs.upload_url }}
asset_path: ./aarch64-apple-darwin.tar.gz
asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-aarch64-apple-darwin.tar.gz
asset_content_type: application/gzip

- name: Upload binaries as artifacts
uses: actions/upload-artifact@v4
with:
name: macos-binaries
path: |
*.tar.gz
upload_assets_windows:
needs: [create_github_release, build_binaries]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Download windows artifact
- name: Download windows artifacts
uses: actions/download-artifact@v4
with:
name: windows-binaries

- name: Upload Windows x86 zipfile
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_github_release.outputs.upload_url }}
asset_path: ./x86_64-pc-windows-msvc.zip
asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-x86_64-pc-windows-msvc.zip
asset_content_type: application/zip

- name: Upload Windows ARM64 zipfile
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_github_release.outputs.upload_url }}
asset_path: ./aarch64-pc-windows-msvc.zip
asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-aarch64-pc-windows-msvc.zip
asset_content_type: application/zip

- name: Upload binaries as artifacts
uses: actions/upload-artifact@v4
with:
name: windows-binaries
path: |
*.zip
upload_assets_linux:
needs: [create_github_release, build_binaries]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Download linux artifact
- name: Download linux artifacts
uses: actions/download-artifact@v4
with:
name: linux-binaries

- name: Upload aarch64-unknown-linux-musl tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_github_release.outputs.upload_url }}
asset_path: ./aarch64-unknown-linux-musl.tar.gz
asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-aarch64-unknown-linux-musl.tar.gz
asset_content_type: application/gzip

- name: Upload x86_64-unknown-linux-musl tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_github_release.outputs.upload_url }}
asset_path: ./x86_64-unknown-linux-musl.tar.gz
asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-x86_64-unknown-linux-musl.tar.gz
asset_content_type: application/gzip

- name: Upload arm-unknown-linux-musleabi tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload all assets
uses: softprops/action-gh-release@v2
with:
upload_url: ${{ needs.create_github_release.outputs.upload_url }}
asset_path: ./arm-unknown-linux-musleabi.tar.gz
asset_name: fta-${{ needs.create_github_release.outputs.version_name }}-arm-unknown-linux-musleabi.tar.gz
asset_content_type: application/gzip
files: |
fta-x86_64-apple-darwin.tar.gz
fta-aarch64-apple-darwin.tar.gz
fta-x86_64-pc-windows-msvc.zip
fta-aarch64-pc-windows-msvc.zip
fta-aarch64-unknown-linux-musl.tar.gz
fta-x86_64-unknown-linux-musl.tar.gz
fta-arm-unknown-linux-musleabi.tar.gz
publish_rust_crate:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -185,7 +94,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "16.x"
node-version: "20.x"
registry-url: "https://registry.npmjs.org"

- name: Download macOS artifacts
Expand All @@ -206,7 +115,7 @@ jobs:
name: windows-binaries
path: artifact/

- name: Extract nix artifacts
- name: Extract .tar.gz artifacts
run: |
for file in artifact/*.tar.gz; do
base=$(basename -- "$file")
Expand All @@ -215,7 +124,7 @@ jobs:
tar -xzf "$file" -C packages/fta/binaries/"$dirname"
done
- name: Extract artifacts
- name: Extract .zip artifacts
run: |
for file in artifact/*.zip; do
dir=$(basename "$file" .zip)
Expand Down
34 changes: 27 additions & 7 deletions packages/fta/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,43 @@ function getBinaryPath() {
switch (platform) {
case "win32":
if (architecture === "x64") {
return path.join(targetDirectory, "x86_64-pc-windows-msvc", "fta.exe");
return path.join(
targetDirectory,
"fta-x86_64-pc-windows-msvc",
"fta.exe"
);
} else if (architecture === "arm64") {
return path.join(targetDirectory, "aarch64-pc-windows-msvc", "fta.exe");
return path.join(
targetDirectory,
"fta-aarch64-pc-windows-msvc",
"fta.exe"
);
}
case "darwin":
if (architecture === "x64") {
return path.join(targetDirectory, "x86_64-apple-darwin", "fta");
return path.join(targetDirectory, "fta-x86_64-apple-darwin", "fta");
} else if (architecture === "arm64") {
return path.join(targetDirectory, "aarch64-apple-darwin", "fta");
return path.join(targetDirectory, "fta-aarch64-apple-darwin", "fta");
}
case "linux":
if (architecture === "x64") {
return path.join(targetDirectory, "x86_64-unknown-linux-musl", "fta");
return path.join(
targetDirectory,
"fta-x86_64-unknown-linux-musl",
"fta"
);
} else if (architecture === "arm64") {
return path.join(targetDirectory, "aarch64-unknown-linux-musl", "fta");
return path.join(
targetDirectory,
"fta-aarch64-unknown-linux-musl",
"fta"
);
} else if (architecture === "arm") {
return path.join(targetDirectory, "arm-unknown-linux-musleabi", "fta");
return path.join(
targetDirectory,
"fta-arm-unknown-linux-musleabi",
"fta"
);
}
break;
default:
Expand Down
15 changes: 9 additions & 6 deletions packages/fta/targets.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// Windows
const exeTargets = ["aarch64-pc-windows-msvc", "x86_64-pc-windows-msvc"];
const exeTargets = [
"fta-aarch64-pc-windows-msvc",
"fta-x86_64-pc-windows-msvc",
];

const plainTargets = [
// macOS
"x86_64-apple-darwin",
"aarch64-apple-darwin",
"fta-x86_64-apple-darwin",
"fta-aarch64-apple-darwin",
// Linux
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"arm-unknown-linux-musleabi",
"fta-x86_64-unknown-linux-musl",
"fta-aarch64-unknown-linux-musl",
"fta-arm-unknown-linux-musleabi",
];

module.exports.exeTargets = exeTargets;
Expand Down

0 comments on commit fa09720

Please sign in to comment.