From e096a4285db91fa0021d96e12f3007d09ff19917 Mon Sep 17 00:00:00 2001 From: Jorge Prendes Date: Tue, 21 Nov 2023 10:19:05 +0000 Subject: [PATCH] simplify release workflow Signed-off-by: Jorge Prendes --- .github/workflows/release.yml | 86 ++++++++++++++--------------------- 1 file changed, 35 insertions(+), 51 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0fe19f2ceb..615bc66887 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,9 +5,21 @@ on: tags: ["v[0-9]+.[0-9]+.[0-9]+*"] jobs: + parse: + runs-on: ubuntu-latest + name: Parse ref + outputs: + version: ${{ steps.parse.outputs.version }} + steps: + - id: parse + name: Parse ref + run: echo "version=${GITHUB_REF##refs/tags/v}" >> ${GITHUB_OUTPUT} + build: name: Build runs-on: ubuntu-20.04 + needs: + - parse strategy: matrix: arch: [ "x86_64", "aarch64" ] @@ -37,75 +49,47 @@ jobs: run: just test-basic test-oci - name: Create output directory run: mkdir output - - name: Copy files to output - run: | - cp youki output/ - cp README.md output/README.md - cp LICENSE output/LICENSE + - name: Create artifact + run: tar -zcvf youki-${{ needs.parse.outputs.version }}-${{ matrix.arch }}.tar.gz youki README.md LICENSE - name: Upload artifact uses: actions/upload-artifact@v3 with: - name: output-${{ matrix.arch }} - path: output/* + name: youki-${{ matrix.arch }} + path: youki-${{ needs.parse.outputs.version }}-${{ matrix.arch }}.tar.gz + release: name: Create Draft Release runs-on: ubuntu-20.04 + permissions: + contents: write needs: + - parse - build steps: - uses: actions/checkout@v3 - - - name: Determine Release Info - id: info - env: - GITHUB_REF: ${{ github.ref }} - run: | - VERSION=${GITHUB_REF##*v} - MAJOR=${VERSION%%.*} - MINOR=${VERSION%.*} - MINOR=${MINOR#*.} - PATCH=${VERSION##*.} - echo "VERSION=${VERSION}" >> $GITHUB_ENV - echo "OUTPUTDIR=youki_${MAJOR}_${MINOR}_${PATCH}_linux" >> $GITHUB_ENV - echo "INNERDIR=youki-${VERSION}" >> $GITHUB_ENV - - - name: Create Output Directory - run: | - mkdir -p ${{ env.OUTPUTDIR }}-x86_64/${{ env.INNERDIR }} - mkdir -p ${{ env.OUTPUTDIR }}-aarch64/${{ env.INNERDIR }} - - - name: Download Linux Artifacts for x86_64 - uses: actions/download-artifact@v3 - with: - name: output-x86_64 - path: ${{ env.OUTPUTDIR }}-x86_64/${{ env.INNERDIR }} - - name: Download Linux Artifacts for aarch64 + - name: Create artifacts directory + run: mkdir -p artifacts + - name: Download artifacts uses: actions/download-artifact@v3 with: - name: output-aarch64 - path: ${{ env.OUTPUTDIR }}-aarch64/${{ env.INNERDIR }} - - name: Restore File Modes - run: | - chmod 755 ${{ env.OUTPUTDIR }}-x86_64/${{ env.INNERDIR }}/youki - chmod 755 ${{ env.OUTPUTDIR }}-aarch64/${{ env.INNERDIR }}/youki - - name: Create tarball + path: artifacts + - name: Show artifacts + run: ls -alhR artifacts + - name: Create release draft + shell: bash run: | - tar -zcvf ${{ env.OUTPUTDIR }}-x86_64.tar.gz ${{ env.OUTPUTDIR }}-x86_64 - tar -zcvf ${{ env.OUTPUTDIR }}-aarch64.tar.gz ${{ env.OUTPUTDIR }}-aarch64 - - name: Create Release Draft - uses: softprops/action-gh-release@v1 - with: - name: ${{ env.VERSION }} Release - draft: true - token: ${{ secrets.GITHUB_TOKEN }} - files: | - ./${{ env.OUTPUTDIR }}-x86_64.tar.gz - ./${{ env.OUTPUTDIR }}-aarch64.tar.gz + set -x + gh release create "${{ github.ref }}" --generate-notes --draft + gh release upload "${{ github.ref }}" artifacts/*/* + env: + GH_TOKEN: ${{ github.token }} + RELEASE_NAME: "${{ needs.parse.outputs.version }} Release" publish: name: Publish Packages needs: build runs-on: ubuntu-20.04 + if: ${{ github.repository == 'containers/youki' }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} steps: