name: Release on: push: branches: - main jobs: release: runs-on: ubuntu-latest outputs: release: ${{ steps.releasable.outputs.release }} release_id: ${{ steps.create_release.outputs.release_id }} version: ${{ steps.next_version.outputs.version }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.CI_TOKEN }} - name: Install Nix uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixos-unstable - name: Set up cachix uses: cachix/cachix-action@v17 with: name: phundrak authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - name: Check for releasable commits id: releasable run: | COUNT=$(nix develop --no-pure-eval --accept-flake-config --command just cliff-count) if [ "$COUNT" -gt 0 ]; then echo "release=true" >> $GITHUB_OUTPUT else echo "release=false" >> $GITHUB_OUTPUT fi - name: Determine next version if: steps.releasable.outputs.release == 'true' id: next_version run: | CLIFF_NEXT_VERSION=$(nix develop --no-pure-eval --accept-flake-config --command just cliff-next-version) echo "version=$CLIFF_NEXT_VERSION" >> $GITHUB_OUTPUT - name: Update changelog if: steps.releasable.outputs.release == 'true' shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}" run: just cliff-bump - name: Create release commit if: steps.releasable.outputs.release == 'true' env: VERSION: ${{ steps.next_version.outputs.version }} shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}" run: just commit-release $VERSION - name: Create version tag if: steps.releasable.outputs.release == 'true' env: VERSION: ${{ steps.next_version.outputs.version }} shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}" run: just create-release-tag $VERSION - name: Create Gitea release if: steps.releasable.outputs.release == 'true' id: create_release env: VERSION: ${{ steps.next_version.outputs.version }} CI_TOKEN: ${{ secrets.CI_TOKEN }} shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}" run: | RESPONSE=$(curl -s -X POST \ -H "Authorization: token $CI_TOKEN" \ -H "Content-Type: application/json" \ "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" \ -d "{\"tag_name\": \"v${VERSION}\", \"name\": \"v${VERSION}\"}") echo "release_id=$(echo "$RESPONSE" | jq -r '.id')" >> $GITHUB_OUTPUT - name: Publish on crates.io if: steps.releasable.outputs.release == 'true' env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}" run: cargo publish - name: Rebase develop onto main if: steps.releasable.outputs.release == 'true' shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}" run: just rebase-develop - name: Bump to next dev version if: steps.releasable.outputs.release == 'true' env: VERSION: ${{ steps.next_version.outputs.version }} shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}" run: just update-develop-version $VERSION build: needs: release if: needs.release.outputs.release == 'true' strategy: matrix: target: ["linux-x86_64", "linux-aarch64", "windows-x86_64"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Nix uses: cachix/install-nix-action@v31 with: nix_path: nixpkgs=channel:nixos-unstable - name: Set up cachix uses: cachix/cachix-action@v17 with: name: phundrak authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - name: Build jj-cz archive run: nix build .#${{ matrix.target }}-archive - name: Upload release asset env: CI_TOKEN: ${{ secrets.CI_TOKEN }} RELEASE_ID: ${{ needs.release.outputs.release_id }} run: | curl -s -X POST \ -H "Authorization: token $CI_TOKEN" \ -F "attachment=@$(ls result/dist/*.zip)" \ "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets"