ci(nix): add archive packages and overhaul CI workflows
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: Publish Docker Images
|
||||
name: Run checks and build archives
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -6,7 +6,7 @@ on:
|
||||
- main
|
||||
- develop
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
- "v*.*.*"
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
@@ -56,32 +56,36 @@ jobs:
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
||||
|
||||
- name: Build Linux release binary
|
||||
run: nix build --no-pure-eval --accept-flake-config
|
||||
build:
|
||||
needs: coverage-and-sonar
|
||||
strategy:
|
||||
matrix:
|
||||
target: ["linux-x86_64", "linux-aarch64", "windows-x86_64"]
|
||||
|
||||
- name: Prepare Linux binary
|
||||
run: |
|
||||
mkdir dist-linux
|
||||
cp result/bin/jj-cz dist-linux/
|
||||
cp LICENSE.*.md dist-linux/
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Upload Linux artifact
|
||||
- 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 artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: jj-cz-x86_64-unknown-linux-gnu
|
||||
path: dist-linux/*
|
||||
|
||||
- name: Build Windows release binary
|
||||
run: nix build .#windows --no-pure-eval --accept-flake-config
|
||||
|
||||
- name: Prepare Windows binary
|
||||
run: |
|
||||
mkdir -p dist-windows
|
||||
cp result/bin/jj-cz.exe dist-windows/
|
||||
cp LICENSE.*.md dist-windows/
|
||||
|
||||
- name: Upload Windows artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: jj-cz-x86_64-pc-windows-gnu
|
||||
path: dist-windows/*
|
||||
name: jj-cz-${{matrix.target}}
|
||||
path: result/dist/*
|
||||
|
||||
@@ -2,33 +2,16 @@ name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
checks:
|
||||
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: Run Checks
|
||||
shell: bash -c "nix develop --no-pure-eval --accept-flake-config --command {0}"
|
||||
run: just check-all
|
||||
|
||||
release:
|
||||
needs: checks
|
||||
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:
|
||||
@@ -49,58 +32,103 @@ jobs:
|
||||
- name: Check for releasable commits
|
||||
id: releasable
|
||||
run: |
|
||||
COUNT=$(nix develop --no-pure-eval --command just cliff-count)
|
||||
echo "count=$COUNT" >> $GITHUB_OUTPUT
|
||||
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.count > 0
|
||||
if: steps.releasable.outputs.release == 'true'
|
||||
id: next_version
|
||||
run: |
|
||||
CLIFF_NEXT_VERSION=$(nix develop --no-pure-eval --command just cliff-next-version)
|
||||
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.count > 0
|
||||
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.count > 0
|
||||
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.count > 0
|
||||
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: Build Linux release binaries
|
||||
if: steps.releasable.outputs.count > 0
|
||||
run: nix build
|
||||
|
||||
- name: Build Windows release binaries
|
||||
if: steps.releasable.outputs.count > 0
|
||||
run: nix build .#windows
|
||||
- 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.count > 0
|
||||
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.count > 0
|
||||
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.count > 0
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user