diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh index 961085e..7f6b457 100755 --- a/.github/workflows/build.sh +++ b/.github/workflows/build.sh @@ -27,7 +27,6 @@ case $OS in setfacl -m u::rwx,g::rwx /home/build setfacl -d --set u::rwx,g::rwx,o::- /home/build chown nobody . - sh ./generate_packages.sh sudo -u nobody makepkg --log mkdir dist @@ -40,7 +39,6 @@ case $OS in ;; "Ubuntu") echo NixOS - sh ./generate_packages.sh export NIXPKGS_ALLOW_UNFREE=1 nix build --impure ;; diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 543bf51..e216ab3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,26 +1,27 @@ name: Build on: + workflow_call: + inputs: + ref: + default: '' + required: false + type: string pull_request: branches: - '*' - push: - branches: - - 'master' jobs: build: - strategy: - matrix: - container: - - archlinux:latest runs-on: ubuntu-latest container: - image: ${{ matrix.container }} + image: archlinux:latest steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ (inputs.ref || '') }} - name: Build run: sh ./.github/workflows/build.sh @@ -50,6 +51,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ (inputs.ref || '') }} - name: Install nix uses: cachix/install-nix-action@v22 @@ -62,31 +65,4 @@ jobs: with: path: ./result/* name: nix-package - - upload-release: - if: github.ref == 'refs/heads/master' - runs-on: ubuntu-latest - needs: [build, nix-build] - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Download artifact - uses: actions/download-artifact@v4 - with: - merge-multiple: true - path: dist - - - name: Retrieve version - run: sh ./.github/workflows/retrieve_version.sh - - - name: Upload files to a GitHub release - uses: ncipollo/release-action@v1.13.0 - with: - allowUpdates: true - artifacts: dist/* - makeLatest: true - name: ${{ env.release_name }} - replacesArtifacts: true - tag: ${{ env.tag_name }} \ No newline at end of file diff --git a/.github/workflows/retrieve_version.sh b/.github/workflows/retrieve_version.sh index f0fa950..9c9196d 100644 --- a/.github/workflows/retrieve_version.sh +++ b/.github/workflows/retrieve_version.sh @@ -1,9 +1,5 @@ #!/bin/bash -# install jq -sudo apt-get update -sudo apt-get install jq - # get version VERSION=$(jq -r '.version' version_info.json) release_name="Beta $VERSION" diff --git a/.github/workflows/update-build-release.yml b/.github/workflows/update-build-release.yml new file mode 100644 index 0000000..fecb61f --- /dev/null +++ b/.github/workflows/update-build-release.yml @@ -0,0 +1,89 @@ +name: Update, build and release + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + push: + branches: + - 'master' + + +jobs: + update_packages: + runs-on: ubuntu-latest + container: + image: archlinux:latest + steps: + - name: Pacman database update + run: pacman -Syy --noconfirm + + - name: Install deps + run: pacman -S --noconfirm git jq + + - name: Checkout + uses: actions/checkout@v4 + + - name: Check and update current packages + run: sh .github/workflows/update_packages.sh + + - name: Retrieve version + run: sh .github/workflows/retrieve_version.sh + + - name: Commit and push changes + uses: EndBug/add-and-commit@v9.1.4 + id: commit + with: + message: "Update packages to ${{ env.release_name }}" + add: "." + author_name: "GitHub Actions" + author_email: "loraner123@gmail.com" + outputs: + new_version: ${{ steps.commit.outputs.commited }} + commit_long_sha: ${{ steps.commit.outputs.commit_long_sha }} + + build: + if: ${{ (github.event_name == 'push') || (needs.update_packages.new_version) }} + needs: update_packages + uses: ./.github/workflows/build.yml + with: + ref: ${{ (needs.update_packages.commit_long_sha || '') }} + + upload-release: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ (needs.build.needs.update_packages.commit_long_sha || '') }} + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: dist + + - name: Retrieve version + run: | + sudo apt-get update + sudo apt-get install jq + sh ./.github/workflows/retrieve_version.sh + + - name: Tag Repo + uses: richardsimko/update-tag@v1 + with: + tag_name: ${{ env.tag_name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload files to a GitHub release + uses: ncipollo/release-action@v1.13.0 + with: + allowUpdates: true + artifacts: dist/* + makeLatest: true + name: ${{ env.release_name }} + replacesArtifacts: true + tag: ${{ env.tag_name }} + \ No newline at end of file diff --git a/.github/workflows/update_packages.yml b/.github/workflows/update_packages.yml deleted file mode 100644 index a41f397..0000000 --- a/.github/workflows/update_packages.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Update packages - -# Controls when the action will run. Workflow runs when manually triggered using the UI -# or API. -on: workflow_dispatch - -jobs: - update_packages: - strategy: - matrix: - container: - - archlinux:latest - runs-on: ubuntu-latest - container: - image: ${{ matrix.container }} - steps: - - name: Pacman database update - run: pacman -Syy --noconfirm - - name: Fix Git - run: pacman -S --noconfirm git - - name: Checkout - uses: actions/checkout@v4 - - name: Check and update current packages - run: sh .github/workflows/update_packages.sh - - name: Save tag name - run: echo "TAG_NAME=v$(jq -r .version ./version_info.json)" >> $GITHUB_ENV - - name: Save version name (Beta x.x.x) - run: echo "VERSION_NAME=Beta $(jq -r .version ./version_info.json)" >> $GITHUB_ENV - - name: Commit and push changes - uses: EndBug/add-and-commit@v9.1.4 - with: - message: "Update packages to ${{ env.VERSION_NAME }}" - add: "." - author_name: "GitHub Actions" - author_email: "loraner123@gmail.com" - tag: ${{ env.TAG_NAME }} - tag_push: '--force' - - \ No newline at end of file