From 363c6e8b71c30b7359204538fb422e561d4250de Mon Sep 17 00:00:00 2001 From: Andrey Onishchenko Date: Mon, 11 Mar 2024 17:48:13 +0300 Subject: [PATCH] Cleanup CI file --- .github/workflows/retrieve_version.sh | 13 --- .github/workflows/update-build-release.yml | 114 ++++++++++++--------- 2 files changed, 63 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/retrieve_version.sh diff --git a/.github/workflows/retrieve_version.sh b/.github/workflows/retrieve_version.sh deleted file mode 100644 index 68a6138..0000000 --- a/.github/workflows/retrieve_version.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -e - -# get version -VERSION=$(jq -r '.ym.version' ./utility/version_info.json) -release_name="Beta $VERSION" -tag_name="v$VERSION" - -#write variables to github env -echo "VERSION=$VERSION" >> $GITHUB_ENV -echo "release_name=$release_name" >> $GITHUB_ENV -echo "tag_name=$tag_name" >> $GITHUB_ENV \ No newline at end of file diff --git a/.github/workflows/update-build-release.yml b/.github/workflows/update-build-release.yml index 3049edf..016d590 100644 --- a/.github/workflows/update-build-release.yml +++ b/.github/workflows/update-build-release.yml @@ -15,36 +15,67 @@ jobs: container: image: archlinux:latest steps: - - name: Packages install - run: pacman -Syy --noconfirm && pacman -S --noconfirm git jq nix python python-requests + + - name: Install dependencies + run: pacman -Syy --noconfirm && pacman -S --noconfirm git jq nix python python-requests - name: Checkout uses: actions/checkout@v4 - - - name: Fix git access - run: - git config --global --add safe.directory "*" - - - name: Update version file - run: python utility/update_version.py + + - name: Git Access Fix + run: git config --global --add safe.directory "*" - name: Update package files - run: python utility/generate_packages.py - - - name: Retrieve version to make commit - run: bash .github/workflows/retrieve_version.sh + run: python utility/update_version.py + python utility/generate_packages.py - name: Commit and push changes uses: EndBug/add-and-commit@v9.1.4 - id: commit + id: commit with: - message: "Update packages to ${{ env.release_name }}" + message: Update packages add: "." - author_name: "GitHub Actions" - author_email: "loraner123@gmail.com" + author_name: GitHub Actions + author_email: loraner123@gmail.com" + + - name: Get Version + id: version + run: VERSION=$(jq -r '.ym.version' ./utility/version_info.json) + release_name="Beta $VERSION" + tag_name="v$VERSION" + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "release_name=$release_name" >> $GITHUB_OUTPUT + echo "tag_name=$tag_name" >> $GITHUB_OUTPUT + + outputs: + commited: ${{ steps.commit.outputs.commited || github.event.head_commit }} + commit_long_sha: ${{ steps.commit.outputs.commit_long_sha || github.event.head_commit.id}} + commit_name: ${{ github.event.head_commit.message || 'Update packages' }} + tag_name: ${{ steps.version.outputs.tag_name }} + release_name: ${{ steps.version.outputs.release_name }} + version: ${{ steps.version.outputs.VERSION }} + + + build: + needs: [update_packages] + uses: ./.github/workflows/build.yml + if: ${{ needs.update_packages.outputs.commited }} + with: + ref: ${{ needs.update_packages.outputs.commit_long_sha }} + + + upload-release: + needs: [build, update_packages] + if: ${{ needs.update_packages.outputs.commited }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ needs.update_packages.outputs.commit_long_sha }} - name: Publish package changes to AUR - if: "${{ github.event.commits[0] || steps.commit.outputs.commited }}" + if: "${{ needs.update_packages.outputs.commited && github.ref_name == 'main' }}" uses: KSXGitHub/github-actions-deploy-aur@v2.7.0 with: pkgname: "yandex-music" @@ -54,60 +85,41 @@ jobs: commit_username: "cucumber-sp" commit_email: "loraner123@gmail.com" ssh_private_key: "${{ secrets.AUR_SSH_PRIVATE_KEY }}" - commit_message: "${{ github.event.commits[0].message || env.release_name }}" + commit_message: "${{ needs.update_packages.outputs.commit_name }}" ssh_keyscan_types: "rsa,dsa,ecdsa,ed25519" - - outputs: - new_version: ${{ steps.commit.outputs.commited }} - commit_long_sha: ${{ steps.commit.outputs.commit_long_sha }} - build: - needs: update_packages - uses: ./.github/workflows/build.yml - with: - ref: ${{ (needs.update_packages.outputs.commit_long_sha || '') }} - - upload-release: - needs: [build, update_packages] - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ (needs.update_packages.outputs.commit_long_sha || '') }} - - - name: Download artifact - uses: actions/download-artifact@v4 + - 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 - bash ./.github/workflows/retrieve_version.sh + - name: Install packages + run: sudo apt-get update -y + sudo apt-get install jq -y - name: Get Release Notes HTML - run: echo "release_html=$(jq -r --arg version "$VERSION" '.["desktop-release-notes." + $version]' ./dist/release_notes.json)" >> $GITHUB_ENV + id: release_notes + run: echo "release_html=$(jq -r --arg version "${{ needs.update_packages.outputs.version }}" '.["desktop-release-notes." + $version]' ./dist/release_notes.json)" >> $GITHUB_OUTPUT - - run: rm -rf dist/release_notes.json + - run: rm -rf dist/release_notes.json - name: Tag Repo uses: richardsimko/update-tag@v1 with: - tag_name: ${{ env.tag_name }} + tag_name: ${{ needs.update_packages.outputs.tag_name}} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload files to a GitHub release uses: ncipollo/release-action@v1.13.0 + if: ${{ github.ref_name == 'main' }} with: allowUpdates: true artifacts: dist/* makeLatest: true - name: ${{ env.release_name }} + name: ${{ needs.update_packages.outputs.release_name }} replacesArtifacts: true - tag: ${{ env.tag_name }} - body: ${{ env.release_html }} + tag: ${{ needs.update_packages.outputs.tag_name }} + body: ${{ steps.release_notes.outputs.release_html }}