From c9842830a1efc1ecdbdd60eab8c1ba20e1290e53 Mon Sep 17 00:00:00 2001 From: Kien Nguyen Date: Sun, 4 Aug 2024 20:47:12 -0700 Subject: [PATCH] ci: upload binaries as soon as build finish --- .github/workflows/build.yml | 84 ++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 40d05c4..fb39b8e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,8 +11,32 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" + prepare_env: + name: Prepare build version + runs-on: ubuntu-latest + env: + EMACS_REPO: https://github.com/kiennq/emacs.git + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v4 + - name: Get build version + id: vars + run: | + mkdir -p ./git/emacs + cd ./git/emacs/ + git clone --depth 1 $EMACS_REPO . + commit=`date +'%Y%m%d'`.`git rev-parse --short=7 HEAD` + major_ver=`cat configure.ac | grep -Po 'AC_INIT\(.*\[\K\d+'` + version=`echo ${major_ver}.${{ github.run_number }}.${commit}` + # bail out if the release existed + echo "version=${version}" >> $GITHUB_ENV + outputs: + repo: ${{ env.EMACS_REPO }} + version: ${{ env.version }} + build: + needs: prepare_env + name: Build Emacs # Matrix strategy from # https://github.com/msys2/MINGW-packages/blob/master/.github/workflows/main.yml strategy: @@ -24,7 +48,7 @@ jobs: msystem: MINGW64 - os: windows-latest shell: powershell - msystem: UCRT64 + msystem: UCRT64 - os: ubuntu-latest shell: bash @@ -32,7 +56,7 @@ jobs: runs-on: ${{ matrix.os }} env: MSYS2_DIR: C:\msys64 - EMACS_REPO: https://github.com/kiennq/emacs.git + EMACS_REPO: ${{ needs.prepare_env.outputs.repo }} defaults: run: @@ -41,7 +65,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Msys2 uses: msys2/setup-msys2@v2 @@ -61,13 +85,6 @@ jobs: mkdir -p ./git/emacs cd ./git/emacs/ git clone --depth 1 $EMACS_REPO . - echo "EMACS_COMMIT=`date +'%Y%m%d'`.`git rev-parse --short=7 HEAD`" >> $GITHUB_ENV - echo "EMACS_MAJOR_VER=`cat configure.ac | grep -Po 'AC_INIT\(.*\[\K\d+'`" >> $GITHUB_ENV - - - name: Set package version - run: | - echo "EMACS_VER=${{ env.EMACS_MAJOR_VER }}.${{ github.run_number }}.${{ env.EMACS_COMMIT }}" >> $GITHUB_ENV - shell: bash - name: Build Emacs if: runner.os == 'Windows' @@ -77,44 +94,25 @@ jobs: - name: Package Emacs if: runner.os == 'Windows' - run: .\emacs-build.cmd --nativecomp --slim --with-rsvg --pack-all + run: | + .\emacs-build.cmd --nativecomp --slim --with-rsvg --pack-all - name: Build and pack Emacs if: runner.os != 'Windows' run: | chmod 755 ./emacs-build-unix.sh mkdir -p ./zips - ./emacs-build-unix.sh -s ./git/emacs/ -v ${{ env.EMACS_VER }} -d ./zips - - # Upload everything - - name: Upload binaries - uses: actions/upload-artifact@v2 - with: - name: emacs-packages - path: zips/* - if-no-files-found: error - - outputs: - version: ${{ env.EMACS_VER }} - - publish: - needs: build - runs-on: ubuntu-latest - steps: - - name: Download binaries - uses: actions/download-artifact@v2 - with: - name: emacs-packages - - run: ls -R + ./emacs-build-unix.sh -s ./git/emacs/ -v ${{ needs.prepare_env.outputs.version }} -d ./zips - # Create release - - name: Create Release - id: create_release - uses: softprops/action-gh-release@v1 + # Upload release for each build + - name: Upload binaries to release + id: upload_release + uses: svenstaro/upload-release-action@v2 with: - tag_name: v${{ needs.build.outputs.version }} - name: emacs_${{ needs.build.outputs.version }} + repo_token: ${{ github.token }} + file: ./zips/*{-full.zip,.deb} + file_glob: true + tag: v${{ needs.prepare_env.outputs.version }} + release_name: emacs_${{ needs.prepare_env.outputs.version }} + draft: false prerelease: false - files: | - *-full.zip - *.deb