From 7be73ba7f9f7452cb5dbe28bf791b7e9d85391e7 Mon Sep 17 00:00:00 2001 From: WanderingPenwing Date: Mon, 22 Jul 2024 16:19:59 +0200 Subject: [PATCH] updated workflow for compiling when release --- .github/workflows/deploy.yml | 97 ----------------------------------- .github/workflows/release.yml | 57 ++++++++++++++++++++ Cargo.toml | 4 +- build/build.rs | 4 ++ calcifer.project | 2 +- 5 files changed, 63 insertions(+), 101 deletions(-) delete mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/release.yml create mode 100644 build/build.rs diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index f38bd2e..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,97 +0,0 @@ -name: Deploy - -on: - push: - tags: - - "[0-9]+.[0-9]+.[0-9]+" - -permissions: - contents: write - -jobs: - build-and-upload: - name: Build and upload - runs-on: ${{ matrix.os }} - - strategy: - matrix: - # You can add more, for any target you'd like! - include: - - build: linux - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - - build: macos - os: macos-latest - target: x86_64-apple-darwin - - - build: windows-gnu - os: windows-latest - target: x86_64-pc-windows-gnu - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Get the release version from the tag - shell: bash - run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y \ - libglib2.0-dev \ - # Add any other dependencies needed by your project - - - name: Debug PKG_CONFIG_PATH - run: echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH" - - - name: Set PKG_CONFIG_PATH - run: export PKG_CONFIG_PATH=/usr/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig - - - name: Debug PKG_CONFIG_PATH - run: echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH" - - - name: Install Rust - # Or @nightly if you want - uses: dtolnay/rust-toolchain@stable - # Arguments to pass in - with: - # Make Rust compile to our target (defined in the matrix) - targets: ${{ matrix.target }} - - - name: Build - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: --verbose --release --target ${{ matrix.target }} - - - name: Build archive - shell: bash - run: | - # Replace with the name of your binary - binary_name="Calcifer" - - dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}" - mkdir "$dirname" - if [ "${{ matrix.os }}" = "windows-latest" ]; then - mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname" - else - mv "target/${{ matrix.target }}/release/$binary_name" "$dirname" - fi - - if [ "${{ matrix.os }}" = "windows-latest" ]; then - 7z a "$dirname.zip" "$dirname" - echo "ASSET=$dirname.zip" >> $GITHUB_ENV - else - tar -czf "$dirname.tar.gz" "$dirname" - echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV - fi - - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: | - ${{ env.ASSET }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c293977 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +permissions: + contents: write + actions: read + checks: write + deployments: write + issues: write + packages: write + pull-requests: write + statuses: write + +on: + release: + types: [created] + +jobs: + release: + name: release ${{ matrix.target }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: [x86_64-pc-windows-gnu, x86_64-unknown-linux-musl] + steps: + - uses: actions/checkout@master + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Compile the app + run: | + cargo build --release --target ${{ matrix.target }} + + - name: Create tarball + run: | + release_tag=${{ github.event.release.tag_name }} + if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-musl" ]]; then + tar -czvf calcifer_v${release_tag}.tar.gz -C target/${{ matrix.target }}/release calcifer + elif [[ "${{ matrix.target }}" == "x86_64-pc-windows-gnu" ]]; then + tar -czvf calcifer_windows_v${release_tag}.tar.gz -C target/${{ matrix.target }}/release calcifer.exe + fi + + - name: Upload release assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: | + calcifer_v${{ github.event.release.tag_name }}.tar.gz + calcifer_windows_v${{ github.event.release.tag_name }}.tar.gz + asset_name: | + calcifer_v${{ github.event.release.tag_name }}.tar.gz + calcifer_windows_v${{ github.event.release.tag_name }}.tar.gz + asset_content_type: application/gzip diff --git a/Cargo.toml b/Cargo.toml index bfa4841..90e50f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "calcifer" version = "1.4.0" edition = "2021" +build = "build/build.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,6 +17,3 @@ nix = { version = "0.27.1", features = ["fs"] } homedir = "0.2.1" arboard = "3.3.0" egui_dnd = "0.6.0" - -[build] -rustflags = ["--cfg=web_sys_unstable_apis"] diff --git a/build/build.rs b/build/build.rs new file mode 100644 index 0000000..90f0304 --- /dev/null +++ b/build/build.rs @@ -0,0 +1,4 @@ +fn main() { + // custom parameter to fix clipboard issue between calcifer and external + println!("cargo:rustc-cfg=web_sys_unstable_apis"); +} diff --git a/calcifer.project b/calcifer.project index 7bffd4e..e55f2ed 100644 --- a/calcifer.project +++ b/calcifer.project @@ -1 +1 @@ -{"categories":[{"name":"to do","content":[{"name":"bug project","description":"when switching tabs between two project file, if item window is open it crashes","id":1},{"name":"update workflow .yml","description":"make a workflow compiling the calcifer and put the linux in calcifer-{version}\nand the windows in calcifer_windows_{version}\n\nupdate nix\nupdate jiji","id":5}]},{"name":"in progress","content":[{"name":"export copy paste fix","description":"// Hello there","id":1}]},{"name":"done","content":[{"name":"move .project file","description":"// Hello there","id":4},{"name":"move config","description":"config from .calcifer/save.json\nto .config/calcifer/state.json","id":1},{"name":"add id to textarea per tab","description":"to improve undo, make each code area of each tab have a unique id (no more undo into another tab)","id":1},{"name":"file tree id ?","description":"// Hello there","id":1},{"name":"open dir in tree ?","description":"// Hello there","id":2},{"name":"fix tab title","description":"// Hello there","id":2}]},{"name":"+","content":[]}]} \ No newline at end of file +{"categories":[{"name":"to do","content":[{"name":"update workflow .yml","description":"make a workflow compiling the calcifer and put the linux in calcifer-{version}\nand the windows in calcifer_windows_{version}\n\nupdate nix\nupdate jiji","id":5}]},{"name":"in progress","content":[{"name":"export copy paste fix","description":"// Hello there","id":1}]},{"name":"done","content":[{"name":"move .project file","description":"// Hello there","id":4},{"name":"move config","description":"config from .calcifer/save.json\nto .config/calcifer/state.json","id":1},{"name":"add id to textarea per tab","description":"to improve undo, make each code area of each tab have a unique id (no more undo into another tab)","id":1},{"name":"file tree id ?","description":"// Hello there","id":1},{"name":"open dir in tree ?","description":"// Hello there","id":2},{"name":"fix tab title","description":"// Hello there","id":2}]},{"name":"+","content":[]}]} \ No newline at end of file