From 458168f1912a433fd79fb25105378efc9eb5994a Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Fri, 3 May 2024 16:05:31 +0800 Subject: [PATCH] refactor: Asset Publishing --- .github/workflows/release.yml | 200 ++++++++++++++++------------------ 1 file changed, 96 insertions(+), 104 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c0488840e..1e2d0516b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,9 @@ on: # types: # - created +env: + AWS_S3_BUCKET: ksp-ckan + jobs: build-release: runs-on: ubuntu-latest @@ -43,6 +46,30 @@ jobs: artifact-configuration-slug: release wait-for-completion: true +# VERSION=$(echo "${{ github.event.release.tag_name }}" | tr -d \"v) + + version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + rpm-version: ${{ steps.version.outputs.rpm-version }} + deb-version: ${{ steps.version.outputs.rpm-version }} + steps: + - name: Get release data + id: version + run: | + VERSION=0.0.0 + echo "Release version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + RPM_VERSION=$(echo ${VERSION}.$(date +'%g%j') | sed -e 's/-/_/g') + echo "RPM version: $VERSION" + echo "rpm-version=$RPM_VERSION" >> $GITHUB_OUTPUT + + DEB_VERSION=${VERSION}.$(date +'%g%j') + echo "deb-version=$DEB_VERSION" >> $GITHUB_OUTPUT + echo "DEB version: $DEB_VERSION" + build-dmg: runs-on: ubuntu-latest needs: build-release @@ -60,10 +87,18 @@ jobs: path: _build/repack/ - name: Build dmg run: ./build osx --configuration=Release --exclusive +# - name: Upload OSX release +# run: gh release upload ${{ github.event.release.tag_name }} _build/osx/CKAN.dmg +# env: +# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} build-deb: runs-on: ubuntu-latest - needs: build-release + needs: + - build-release + - version + env: + DEB_VERSION: ${{ needs.version.output.deb-version }} steps: - uses: actions/checkout@v4 - name: Setup .NET Core @@ -91,10 +126,26 @@ jobs: DEBIAN_PRIVATE_KEY: ${{ secrets.DEBIAN_PRIVATE_KEY }} run: ./build deb-sign --configuration=Release --exclusive if: ${{ env.DEBIAN_PRIVATE_KEY }} + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Push deb to S3 + run: aws s3 sync _build/deb/apt-repo-root s3://${AWS_S3_BUCKET}/test/deb --follow-symlinks + - name: Push stable APT repo to S3 + run: aws s3 sync _build/deb/apt-repo-dist s3://${AWS_S3_BUCKET}/test/deb/dists/stable --follow-symlinks +# - name: Upload Deb release +# run: gh release upload ${{ github.event.release.tag_name }} _build/deb/ckan_${DEB_VERSION}_all.deb +# env: +# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} build-rpm: runs-on: ubuntu-latest needs: build-release + env: + RPM_VERSION: ${{ needs.version.output.rpm-version }} steps: - uses: actions/checkout@v4 - name: Installing rpm build dependencies @@ -121,109 +172,50 @@ jobs: DEBIAN_PRIVATE_KEY: ${{ secrets.DEBIAN_PRIVATE_KEY }} run: ./build rpm-repo --configuration=Release --exclusive if: ${{ env.DEBIAN_PRIVATE_KEY }} - -# - name: Get release data -# id: release_data -# run: | -# URL=$(wget -qO- https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq '.[0].upload_url' | tr -d \") -# echo "upload_url=$URL" >> $GITHUB_OUTPUT -# VERSION=$(wget -qO- https://api.github.com/repos/$GITHUB_REPOSITORY/releases | jq '.[0].tag_name' | tr -d \"v) -# echo "version=$VERSION" >> $GITHUB_OUTPUT -# RPM_VERSION=$(echo ${VERSION}.$(date +'%g%j') | sed -e 's/-/_/g') -# echo "rpm_version=$RPM_VERSION" >> $GITHUB_OUTPUT -# DEB_VERSION=${VERSION}.$(date +'%g%j') -# echo "deb_version=$DEB_VERSION" >> $GITHUB_OUTPUT -# - name: Push deb to S3 -# # Send deb file to https://ksp-ckan.s3-us-west-2.amazonaws.com/ -# uses: jakejarvis/s3-sync-action@master -# with: -# args: --follow-symlinks -# env: -# AWS_S3_BUCKET: ksp-ckan -# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} -# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# AWS_REGION: us-east-1 -# SOURCE_DIR: _build/deb/apt-repo-root -# DEST_DIR: deb -# if: ${{ env.AWS_ACCESS_KEY_ID && env.AWS_SECRET_ACCESS_KEY }} -# - name: Push stable APT repo to S3 -# uses: jakejarvis/s3-sync-action@master -# with: -# args: --follow-symlinks -# env: -# AWS_S3_BUCKET: ksp-ckan -# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} -# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# AWS_REGION: us-east-1 -# SOURCE_DIR: _build/deb/apt-repo-dist -# DEST_DIR: deb/dists/stable -# if: ${{ env.AWS_ACCESS_KEY_ID && env.AWS_SECRET_ACCESS_KEY }} -# - name: Push stable RPM repo to S3 -# uses: jakejarvis/s3-sync-action@master -# with: -# args: --follow-symlinks + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Push rpm to S3 + run: aws s3 sync _build/rpm/repo s3://${AWS_S3_BUCKET}/test/rpm/stable --follow-symlinks +# - name: Upload RPM release +# run: gh release upload ${{ github.event.release.tag_name }} _build/rpm/RPMS/noarch/ckan-${RPM_VERSION}-1.noarch.rpm # env: -# AWS_S3_BUCKET: ksp-ckan -# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} -# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# AWS_REGION: us-east-1 -# SOURCE_DIR: _build/rpm/repo -# DEST_DIR: rpm/stable -# if: ${{ env.AWS_ACCESS_KEY_ID && env.AWS_SECRET_ACCESS_KEY }} -# +# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + upload-binaries: + runs-on: ubuntu-latest + needs: build-release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/download-artifact@v4 + with: + name: repack-unsigned + path: _build/repack/ + - run: ls -lah _build/repack/ # - name: Upload ckan.exe -# uses: actions/upload-release-asset@v1.0.1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ steps.release_data.outputs.upload_url }} -# asset_path: _build/repack/Release/ckan.exe -# asset_name: ckan.exe -# asset_content_type: application/vnd.microsoft.portable-executable -# - name: Upload CKAN.dmg -# uses: actions/upload-release-asset@v1.0.1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ steps.release_data.outputs.upload_url }} -# asset_path: _build/osx/CKAN.dmg -# asset_name: CKAN.dmg -# asset_content_type: application/x-apple-diskimage -# - name: Upload ckan_*.deb -# uses: actions/upload-release-asset@v1.0.1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ steps.release_data.outputs.upload_url }} -# asset_path: _build/deb/ckan_${{ steps.release_data.outputs.deb_version }}_all.deb -# asset_name: ckan_${{ steps.release_data.outputs.version }}_all.deb -# asset_content_type: application/vnd.debian.binary-package -# - name: Upload ckan-*.rpm -# uses: actions/upload-release-asset@v1.0.1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ steps.release_data.outputs.upload_url }} -# asset_path: _build/rpm/RPMS/noarch/ckan-${{ steps.release_data.outputs.rpm_version }}-1.noarch.rpm -# asset_name: ckan-${{ steps.release_data.outputs.version }}-1.noarch.rpm -# asset_content_type: application/x-rpm +# run: gh release upload ${{ github.event.release.tag_name }} _build/repack/Release/ckan.exe # - name: Upload AutoUpdater.exe -# uses: actions/upload-release-asset@v1.0.1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ steps.release_data.outputs.upload_url }} -# asset_path: _build/repack/Release/AutoUpdater.exe -# asset_name: AutoUpdater.exe -# asset_content_type: application/vnd.microsoft.portable-executable -# -# - name: Send Discord Notification -# env: -# JOB_STATUS: ${{ job.status }} -# WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK }} -# HOOK_OS_NAME: ${{ runner.os }} -# WORKFLOW_NAME: ${{ github.workflow }} -# if: ${{ always() && env.WEBHOOK_URL }}] -# run: | -# git clone --depth 1 https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook -# bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL +# run: gh release upload ${{ github.event.release.tag_name }} _build/repack/Release/AutoUpdater.exe + + notify-discord: + runs-on: ubuntu-latest + needs: + - build-dmg + - build-deb + - build-rpm + - upload-binaries + steps: + - name: Send Discord Notification + env: + JOB_STATUS: ${{ job.status }} + WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK }} + HOOK_OS_NAME: ${{ runner.os }} + WORKFLOW_NAME: ${{ github.workflow }} + if: ${{ always() && env.WEBHOOK_URL }}] + run: | + git clone --depth 1 https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook + bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL