Skip to content

Commit

Permalink
generating dotslash file
Browse files Browse the repository at this point in the history
  • Loading branch information
perryqh committed May 28, 2024
1 parent c7595ac commit 6ff329b
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 13 deletions.
64 changes: 51 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,36 +87,52 @@ jobs:
if [[ -n $VERSION_CHANGES ]]; then
NEW_VERSION=$(echo $VERSION_CHANGES | awk -F'"' '{print $2}')
echo "changed=true" >> $GITHUB_OUTPUT
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "new_version=v$NEW_VERSION" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: cargo publish and create GitHub Release if current commit has updated the version in Cargo.toml
if: steps.check_for_version_changes.outputs.changed == 'true'
run: |
gh release create ${{steps.check_for_version_changes.outputs.new_version}} --target "${{ github.sha }}" --generate-notes
cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Skip publishing
if: steps.check_for_version_changes.outputs.changed == 'false'
run: |
echo "No diff to the version found in Cargo.toml. Skipping publishing."
upload-mac-universal-bin:
needs: release
runs-on: macos-latest
if: github.ref == 'refs/heads/main' && ${{needs.release.outputs.changed}} == 'true'
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --release --target aarch64-apple-darwin --target x86_64-apple-darwin

- name: create GitHub Release
run: |
# This combines the intel and m1 binaries into a single binary
lipo -create -output target/packs target/aarch64-apple-darwin/release/packs target/x86_64-apple-darwin/release/packs
# Creates artifact for homebrew. -C means run from `target` directory
tar -czf target/packs-mac.tar.gz -C target packs
gh release create v${{steps.check_for_version_changes.outputs.new_version}} --target "${{ github.sha }}" --generate-notes
# This uploads the raw binary
gh release upload v${{steps.check_for_version_changes.outputs.new_version}} target/packs
gh release upload $NEW_VERSION target/packs
# This tarball is a binary that is executable
gh release upload v${{steps.check_for_version_changes.outputs.new_version}} target/packs-mac.tar.gz
gh release upload $NEW_VERSION target/packs-mac.tar.gz
cargo publish
#cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Skip publishing
if: steps.check_for_version_changes.outputs.changed == 'false'
run: |
echo "No diff to the version found in Cargo.toml. Skipping publishing."
NEW_VERSION: ${{ needs.release.outputs.new_version }}

upload-linux-bin:
needs: release
if: github.ref == 'refs/heads/main' && ${{needs.release.outputs.changed}} == 'true'
Expand All @@ -134,9 +150,31 @@ jobs:
run: |
tar -czf target/x86_64-unknown-linux-gnu.tar.gz -C target/x86_64-unknown-linux-gnu/release pks packs
tar -czf target/aarch64-unknown-linux-gnu.tar.gz -C target/aarch64-unknown-linux-gnu/release pks packs
gh release upload v$NEW_VERSION target/x86_64-unknown-linux-gnu.tar.gz
gh release upload v$NEW_VERSION target/aarch64-unknown-linux-gnu.tar.gz
gh release upload $NEW_VERSION target/x86_64-unknown-linux-gnu.tar.gz
gh release upload $NEW_VERSION target/aarch64-unknown-linux-gnu.tar.gz
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_VERSION: ${{ needs.release.outputs.new_version }}

generate-dotslash-files:
name: Generating and uploading DotSlash files
needs:
- release
- upload-linux-bin
- upload-mac-universal-bin
if: success() && github.ref == 'refs/heads/main' && ${{needs.release.outputs.changed}} == 'true'
runs-on: ubuntu-latest

steps:
- uses: facebook/dotslash-publish-release@v1
# This is necessary because the action uses
# `gh release upload` to publish the generated DotSlash file(s)
# as part of the release.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Additional file that lives in your repo that defines
# how your DotSlash file(s) should be generated.
config: .github/workflows/dotslash-config.json
# Tag for the release to target.
tag: ${{ needs.release.outputs.new_version }}
28 changes: 28 additions & 0 deletions .github/workflows/dotslash-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"outputs": {
"pks": {
"platforms": {
"macos-x86_64": {
"regex": "^packs-mac",
"path": "packs",
"format": "tar.gz"
},
"macos-aarch64": {
"regex": "^packs-mac",
"path": "packs",
"format": "tar.gz"
},
"linux-x86_64": {
"regex": "^x86_64-unknown-linux",
"path": "packs",
"format": "tar.gz"
},
"linux--aarch64": {
"regex": "^aarch64-unknown-linux",
"path": "packs",
"format": "tar.gz"
}
}
}
}
}

0 comments on commit 6ff329b

Please sign in to comment.