diff --git a/.github/workflows/create-image.yml b/.github/workflows/create-image.yml index 27b0466..7071dc9 100644 --- a/.github/workflows/create-image.yml +++ b/.github/workflows/create-image.yml @@ -4,29 +4,70 @@ name: CI # Controls when the workflow will run on: push: + tags: + - '*' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: + # This workflow contains a single job called "build" build: - runs-on: macos-12 - name: A job to run test in FreeBSD - env: - GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} + # The type of runner that the job will run on + runs-on: self-hosted + + # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name: Get tag name - run: echo "REF_NAME=$(echo ${GITHUB_REF##*/} | tr / -)" >> $GITHUB_ENV - - uses: actions/checkout@v3 - - name: Run build.sh - uses: vmactions/freebsd-vm@v0 - with: - envs: 'GITHUB_TOKEN REF_NAME' - usesh: true - prepare: | - pkg install -y bash qemu git + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + + - name: Get tag name + run: echo "REF_NAME=$(echo ${GITHUB_REF##*/} | tr / -)" >> $GITHUB_ENV + + - name: Debug + run: echo ${{ env.REF_NAME }} + + # Run building script + - name: Run build.sh + run: | + sudo chmod +x build.sh + sudo ./build.sh ${{ env.REF_NAME }} + + # Converting image + - name: Converting image to QCOW2 format run: | - chmod +x build.sh - ./build.sh 13.2 - qemu-img convert -f raw -O qcow2 -c -S 4k final.raw freebsd-13.2-amd64.qcow2 - md5sum freebsd-13.2-amd64.qcow2 > md5.txt + sudo qemu-img convert -f raw -O qcow2 -c -S 4k final.raw freebsd-${{ env.REF_NAME }}-amd64.qcow2 + sudo md5sum freebsd-${{ env.REF_NAME }}-amd64.qcow2 > md5.txt + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.REF_NAME }} + release_name: FreeBSD version ${{ env.REF_NAME }} + draft: false + prerelease: false + + - name: Upload image to release asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: freebsd-${{ env.REF_NAME }}-amd64.qcow2 + asset_name: freebsd-${{ env.REF_NAME }}-amd64.qcow2 + asset_content_type: application/octet-stream + + - name: Add md5.txt file + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: md5.txt + asset_name: md5.txt + asset_content_type: text/plain +