From c168c3956cf77886c14133ac10ec33aa0ae5bc4e Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Thu, 6 Feb 2025 19:43:44 +0300 Subject: [PATCH] misc(workflow): Some improvements (#1810) * misc(workflow): Some improvements * Updated * Update cd.yml * Update schedule.yml * Create cd.yml * Update cd.yml * Update schedule.yml * Update cd.yml --- .github/workflows/cd.yml | 63 ++++-------------------------- .github/workflows/ci.yml | 13 ++++--- .github/workflows/schedule.yml | 71 ++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/schedule.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index c7302d736..5073faf40 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -6,8 +6,9 @@ on: - "v*.*.*" jobs: - changelog: - runs-on: ubuntu-latest + generate-changelog: + name: Generate changelog + runs-on: ubuntu-22.04 outputs: release_body: ${{ steps.git-cliff.outputs.content }} steps: @@ -15,72 +16,24 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - token: ${{ secrets.REPO_TOKEN }} - name: Generate a changelog uses: orhun/git-cliff-action@v4 id: git-cliff with: config: cliff.toml - args: v2.4.5-rc.2.. --verbose - env: - OUTPUT: CHANGELOG.md - GITHUB_REPO: ${{ github.repository }} + args: -vv --latest --no-exec --github-repo ${{ github.repository }} - name: Print the changelog run: cat "${{ steps.git-cliff.outputs.changelog }}" - - name: Commit changelog - run: | - git checkout master - git config --local user.name 'belomaxorka' - git config --local user.email 'roman25052006.kelesh@gmail.com' - set +e - git add CHANGELOG.md - git commit -m "release(preparing): Update CHANGELOG.md 📖" - git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git master - - checksums: - runs-on: ubuntu-latest - needs: - - changelog - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: master - token: ${{ secrets.REPO_TOKEN }} - - - name: Generate checksums.md5 file - run: | - find . -type f -not -path "./.git/*" -exec md5sum {} \; > internal_data/checksums.md5 - - - name: Commit and push checksums.md5 if changed - run: | - git checkout master - git config --local user.name 'belomaxorka' - git config --local user.email 'roman25052006.kelesh@gmail.com' - - if git diff --quiet internal_data/checksums.md5; then - echo "No changes in internal_data/checksums.md5" - else - set +e - git add internal_data/checksums.md5 - git commit -m "release(preparing): Update checksums.md5 📄" - git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git master - fi - release: name: Create release - needs: - - checksums - - changelog + needs: [ generate-changelog ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set the release version shell: bash run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV @@ -106,11 +59,10 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ steps.create_zip.outputs.ZIP_NAME }} - file_glob: true overwrite: true tag: ${{ github.ref }} release_name: "TorrentPier v${{ env.RELEASE_VERSION }}" - body: "${{ needs.changelog.outputs.release_body }}" + body: "${{ needs.generate-changelog.outputs.release_body }}" - name: Publish to GitHub (pre-release) if: ${{ contains(github.ref, '-') }} @@ -118,9 +70,8 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ steps.create_zip.outputs.ZIP_NAME }} - file_glob: true overwrite: true tag: ${{ github.ref }} release_name: "TorrentPier v${{ env.RELEASE_VERSION }}" - body: "${{ needs.changelog.outputs.release_body }}" + body: "${{ needs.generate-changelog.outputs.release_body }}" prerelease: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1579e9a1..9822d188a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,34 +7,35 @@ on: jobs: nightly: + name: Nightly builds 📦 runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Checkout code 🗳 uses: actions/checkout@v4 - - name: Setup PHP + - name: Setup PHP 🔩 uses: shivammathur/setup-php@v2 with: php-version: '8.1' - - name: Install Composer dependencies + - name: Install Composer dependencies 🪚 run: composer install --no-progress --prefer-dist --optimize-autoloader - - name: Get commit hash + - name: Get commit hash 🔗 id: get_commit_hash run: | COMMIT_HASH=$(git rev-parse --short HEAD) echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_OUTPUT - - name: Create archive + - name: Create archive 🗞 id: create_zip run: | ZIP_NAME="torrentpier-${{ steps.get_commit_hash.outputs.COMMIT_HASH }}.zip" zip -r "$ZIP_NAME" . -x ".git/*" ".github/*" echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_OUTPUT - - name: Upload Archive + - name: Upload Archive 📤 uses: actions/upload-artifact@v4 with: name: TorrentPier diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml new file mode 100644 index 000000000..35d132473 --- /dev/null +++ b/.github/workflows/schedule.yml @@ -0,0 +1,71 @@ +name: Changelog & checksums generation + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + changelog: + name: Changelog generation + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: master + token: ${{ secrets.REPO_TOKEN }} + + - name: Generate a changelog + uses: orhun/git-cliff-action@v4 + id: git-cliff + with: + config: cliff.toml + args: v2.4.5-rc.2.. --verbose + env: + OUTPUT: CHANGELOG.md + GITHUB_REPO: ${{ github.repository }} + + - name: Print the changelog + run: cat "${{ steps.git-cliff.outputs.changelog }}" + + - name: Commit changelog + run: | + git checkout master + git config --local user.name 'belomaxorka' + git config --local user.email 'roman25052006.kelesh@gmail.com' + set +e + git add CHANGELOG.md + git commit -m "Update CHANGELOG.md 📖" + git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git master + + checksums: + name: Generate checksums.md5 file + runs-on: ubuntu-latest + needs: [ changelog ] + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: master + token: ${{ secrets.REPO_TOKEN }} + + - name: Generate checksums.md5 file + run: | + find . -type f -not -path "./.git/*" -exec md5sum {} \; > internal_data/checksums.md5 + + - name: Commit and push checksums.md5 if changed + run: | + git checkout master + git config --local user.name 'belomaxorka' + git config --local user.email 'roman25052006.kelesh@gmail.com' + + if git diff --quiet internal_data/checksums.md5; then + echo "No changes... " + else + set +e + git add internal_data/checksums.md5 + git commit -m "Update checksums.md5 📄" + git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git master + fi