ci: only create nightly release if build passes (#590)

Changes the nightly build workflow to delete/create a new release *only* if the entire build process passes. This avoids a potential case of a nightly build failing but having overwritten the old one, which has happened before.

After this change lands, similar changes will probably be made to the deployment script for releases.
This commit is contained in:
Clement Tsang 2021-10-03 02:42:37 -04:00 committed by GitHub
parent 865d0dac78
commit 9071e37283
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 91 additions and 109 deletions

View File

@ -450,7 +450,7 @@ jobs:
- name: Execute choco packaging script
run: |
python "./deployment/windows/choco/choco_packager.py" "./artifacts/bottom_i686-pc-windows-msvc.zip" "./artifacts/bottom_x86_64-pc-windows-msvc.zip" ${{ env.RELEASE_VERSION }} "./deployment/windows/choco/bottom.nuspec.template" "./deployment/windows/choco/chocolateyinstall.ps1.template" "bottom.nuspec" "tools/chocolateyinstall.ps1" "tools/"
python "./deployment/windows/choco/choco_packager.py" "./artifacts/bottom_i686-pc-windows-msvc.zip" "./artifacts/bottom_x86_64-pc-windows-msvc.zip" ${{ env.RELEASE_VERSION }} "./deployment/windows/choco/bottom.nuspec.template" "./deployment/windows/choco/chocolatey_install.ps1.template" "bottom.nuspec" "tools/chocolatey_install.ps1" "tools/"
zip -r choco.zip "bottom.nuspec" "tools"
- name: Upload choco.zip to release

View File

@ -14,13 +14,10 @@ on:
required: false
jobs:
create-github-release:
name: create-github-release
initialize-job:
name: initialize-job
runs-on: ubuntu-latest
steps:
- name: Create artifacts directory
run: mkdir artifacts
- name: Check if mock
run: |
echo "${{ github.event.inputs.isMock }}";
@ -32,45 +29,19 @@ jobs:
echo "This is NOT a mock run. Watch for the generated files!"
fi
- name: Delete tag and release
uses: dev-drprasad/delete-tag-and-release@v0.1.3
if: github.event.inputs.isMock != 'mock'
with:
delete_release: true
tag_name: nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sleep for a few seconds to prevent timing issues between the deletion and creation of the release
run: sleep 10
- name: Create nightly GitHub release
id: release
uses: actions/create-release@v1
if: github.event.inputs.isMock != 'mock'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: false
tag_name: nightly
release_name: nightly
prerelease: true
- name: Save release upload URL to artifact
run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url
- name: Save version number to artifact
run: echo "nightly" > artifacts/release-version
run: echo "nightly" > release-version
- name: Upload artifacts
uses: actions/upload-artifact@v1
- name: Upload release-version as artifact
uses: actions/upload-artifact@v2
with:
name: artifacts
path: artifacts
retention-days: 1
name: release-version
path: release-version
build-release:
name: build-release
needs: [create-github-release]
needs: [initialize-job]
runs-on: ${{ matrix.triple.os }}
container: ${{ matrix.triple.container }}
env:
@ -164,25 +135,6 @@ jobs:
with:
fetch-depth: 1
- name: Get release download URL
uses: actions/download-artifact@v2
with:
name: artifacts
path: artifacts
- name: Set release upload URL and release version
shell: bash
run: |
release_upload_url="$(cat ./artifacts/release-upload-url)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
release_version="$(cat ./artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables
run: |
echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}"
echo "Release version: ${{ env.RELEASE_VERSION }}"
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
@ -232,38 +184,29 @@ jobs:
tar -czvf bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz btm completion
echo "ASSET=bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz" >> $GITHUB_ENV
- name: Upload main release
if: github.event.inputs.isMock != 'mock'
uses: actions/upload-release-asset@v1.0.1
id: upload
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
- name: Create release directory for artifact, move file
shell: bash
run: |
mkdir release
mv ${{ env.ASSET }} release
- name: Compress completion files (Linux x86-64 GNU)
if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == ''
shell: bash
run: |
tar -C ./completion -czvf completion.tar.gz .
mv completion.tar.gz release
- name: Release completion files (Linux x86-64 GNU)
if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' && github.event.inputs.isMock != 'mock'
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save release files as artifacts
uses: actions/upload-artifact@v2
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: completion.tar.gz
asset_name: completion.tar.gz
asset_content_type: application/octet-stream
retention-days: 1
name: release
path: release
build-msi:
name: build-msi
needs: [create-github-release]
needs: [initialize-job]
runs-on: "windows-2019"
env:
RUST_BACKTRACE: 1
@ -276,20 +219,17 @@ jobs:
- name: Get release download URL
uses: actions/download-artifact@v2
with:
name: artifacts
path: artifacts
name: release-version
path: release-version
- name: Set release upload URL and release version
- name: Set release version
shell: bash
run: |
release_upload_url="$(cat ./artifacts/release-upload-url)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
release_version="$(cat ./artifacts/release-version)"
release_version="$(cat ./release-version/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables
run: |
echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}"
echo "Release version: ${{ env.RELEASE_VERSION }}"
- name: Install Net-Framework-Core
@ -320,20 +260,22 @@ jobs:
cargo wix init
cargo wix
- name: Upload msi file
if: github.event.inputs.isMock != 'mock'
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release directory for artifact, move file
shell: bash
run: |
mkdir release
mv bottom_x86_64_installer.msi release
- name: Save msi file as artifacts
uses: actions/upload-artifact@v2
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: bottom_x86_64_installer.msi
asset_name: bottom_x86_64_installer.msi
asset_content_type: application/octet-stream
retention-days: 1
name: release
path: release
build-deb:
name: build-deb
needs: [create-github-release]
needs: [initialize-job]
runs-on: "ubuntu-18.04"
env:
RUST_BACKTRACE: 1
@ -346,20 +288,17 @@ jobs:
- name: Get release download URL
uses: actions/download-artifact@v2
with:
name: artifacts
path: artifacts
name: release-version
path: release-version
- name: Set release upload URL and release version
shell: bash
run: |
release_upload_url="$(cat ./artifacts/release-upload-url)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
release_version="$(cat ./artifacts/release-version)"
release_version="$(cat ./release-version/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables
run: |
echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}"
echo "Release version: ${{ env.RELEASE_VERSION }}"
- name: Install toolchain
@ -380,13 +319,56 @@ jobs:
cargo deb
cp ./target/debian/bottom_*.deb ./bottom_${{ env.RELEASE_VERSION }}_amd64.deb
- name: Upload Debian file if not mock
- name: Create release directory for artifact, move file
shell: bash
run: |
mkdir release
mv bottom_${{ env.RELEASE_VERSION }}_amd64.deb release
- name: Save Debian file as artifacts
uses: actions/upload-artifact@v2
with:
retention-days: 1
name: release
path: release
upload-release:
name: upload-release
runs-on: ubuntu-latest
needs: [build-release, build-deb, build-msi]
steps:
- name: Get release artifacts
uses: actions/download-artifact@v2
with:
name: release
path: release
- name: Print out all release files
run: |
echo "Generated $(ls ./release | wc -l) files:"
ls ./release
- name: Delete tag and release
uses: dev-drprasad/delete-tag-and-release@v0.1.3
if: github.event.inputs.isMock != 'mock'
uses: actions/upload-release-asset@v1.0.1
with:
delete_release: true
tag_name: nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sleep for a few seconds to prevent timing issues between the deletion and creation of the release
run: sleep 10
if: github.event.inputs.isMock != 'mock'
- name: Upload all saved release files if not mock
uses: softprops/action-gh-release@v1
if: github.event.inputs.isMock != 'mock'
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: bottom_${{ env.RELEASE_VERSION }}_amd64.deb
asset_name: bottom_${{ env.RELEASE_VERSION }}_amd64.deb
asset_content_type: application/octet-stream
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
tag_name: "nightly"
draft: false
fail_on_unmatched_files: true
files: |
./release/*

View File

@ -49,7 +49,7 @@ with open(deployment_file_path_32, "rb") as deployment_file_32, open(
with open(ps1_template, "r") as template_file:
template = Template(template_file.read())
substitute = template.safe_substitute(version=version, hash_32=hash_32, hash_64=hash_64)
print("\n================== Generated chocolateyinstall file ==================\n")
print("\n================== Generated chocolatey-install file ==================\n")
print(substitute)
print("\n============================================================\n")