Skip to content

Commit

Permalink
chore: use xz compress
Browse files Browse the repository at this point in the history
  • Loading branch information
Hintay committed Nov 16, 2024
1 parent 05240e5 commit 5cd5e69
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: 'Clone ${{ matrix.repo }}'
run: 'git clone https://github.com/${{ matrix.repo }} mcm'
- name: Clone ${{ matrix.repo }}
run: git clone https://github.com/${{ matrix.repo }} mcm

- name: Set ${{ matrix.target }} musl with configurations
if: matrix.repo == 'userdocs/qbt-musl-cross-make'
Expand All @@ -106,40 +106,40 @@ jobs:
run: cat config.mak
working-directory: mcm

- name: 'Build ${{ matrix.target }}'
- name: Build ${{ matrix.target }}
run: |-
make -j4
make install
ls output
working-directory: mcm

- name: 'Package ${{ matrix.target }}'
- name: Package ${{ matrix.target }}
id: package
run: |-
tar -czvf ../output-${{ matrix.target }}.tar.gz output/
XZ_OPT=-9T0 tar -cvJf ../output-${{ matrix.target }}.tar.xz output/
echo "source_escaped=${REPO%%/*}_${REPO##*/}" >> $GITHUB_OUTPUT
working-directory: mcm

- id: upload-artifacts
name: Upload artifacts
if: '${{ success() }}'
if: ${{ success() }}
uses: cytopia/[email protected]
with:
path: 'output-${{ matrix.target }}.tar.gz'
name: '${{ matrix.target }}-${{ steps.package.outputs.source_escaped }}'
path: output-${{ matrix.target }}.tar.xz
name: ${{ matrix.target }}-${{ steps.package.outputs.source_escaped }}

- name: Rename artifact
run: mv output-${{ matrix.target }}.tar.gz output-${{ matrix.target }}-${{ steps.package.outputs.source_escaped }}.tar.gz
run: mv output-${{ matrix.target }}.tar.xz output-${{ matrix.target }}-${{ steps.package.outputs.source_escaped }}.tar.xz

- id: upload-releases
name: Upload to releases
uses: ncipollo/release-action@v1
if: '${{ github.event.inputs.do_release }}'
if: ${{ github.event.inputs.do_release }}
with:
allowUpdates: true
tag: '${{ github.event.inputs.release }}'
artifacts: 'output-${{ matrix.target }}*.tar.gz'
tag: ${{ github.event.inputs.release }}
artifacts: output-${{ matrix.target }}*.tar.xz
artifactContentType: application/gzip
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

14 changes: 9 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const tags = {
const url = `https://github.com/nginxui/musl-cross-compilers/releases/download/${tags[variant]}/output-${target}-${variant.replace(
"/",
"_"
)}.tar.gz`;
)}.tar.xz`;

let cachedPath;
if (build) {
Expand Down Expand Up @@ -70,14 +70,14 @@ const tags = {
}
cachedPath = destDir;
} else {
cachedPath = tc.find("mcm", `${target}-${variant}.tar.gz`);
cachedPath = tc.find("mcm", `${target}-${variant}.tar.xz`);
}
if (cachedPath) {
console.log(`Found installation at ${cachedPath}`);
} else {
const toolchainPath = await tc.downloadTool(url);
const toolchainExtractedFolder = await tc.extractTar(toolchainPath);
cachedPath = await tc.cacheDir(toolchainExtractedFolder, "mcm", `${target}-${variant}.tar.gz`);
cachedPath = await tc.cacheDir(toolchainExtractedFolder, "mcm", `${target}-${variant}.tar.xz`);
console.log(`Installed at ${cachedPath}`);
}
cachedPath = path.join(cachedPath, "output", "bin");
Expand All @@ -87,11 +87,15 @@ const tags = {
} catch (e) {
if (build) {
console.log("Build error occurred and uploading build directory as artifacts");
await exec.exec("tar", ["-czf", "/opt/mcm.tar.gz", buildDir]);
await exec.exec("tar", ["-cJf", "/opt/mcm.tar.xz", buildDir], {
env: {
XZ_OPT: "-9T0"
}
});
const artifact = require("@actions/artifact");
const artifactClient = artifact.create();
const artifactName = `musl-cross-compiler-error-${target}-${variant.replace("/", "_")}`;
const files = ["/opt/mcm.tar.gz"];
const files = ["/opt/mcm.tar.xz"];
const rootDirectory = "/opt/";
const options = {};
await artifactClient.uploadArtifact(artifactName, files, rootDirectory, options);
Expand Down

0 comments on commit 5cd5e69

Please sign in to comment.