ci: Create release only if the entire pipeline passes (#595)

In a similar vein to #590, we only create a release after the entire pipeline is completed and succeeds. Also fixes some incorrect job names and adds some "/'s" after directory names in the nightly pipeline.
This commit is contained in:
Clement Tsang 2021-10-09 02:29:17 -04:00 committed by GitHub
parent a1a33e0120
commit a362b6c9dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 148 additions and 160 deletions

View File

@ -15,13 +15,10 @@ on:
- "[0-9]+.[0-9]+.[0-9]+" - "[0-9]+.[0-9]+.[0-9]+"
jobs: jobs:
create-github-release: initialize-release-job:
name: create-github-release name: initialize-release-job
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Create artifacts directory
run: mkdir artifacts
- name: Get the release version from the tag - name: Get the release version from the tag
if: env.VERSION == '' if: env.VERSION == ''
run: | run: |
@ -36,31 +33,19 @@ jobs:
run: | run: |
echo "Version being built against is version ${{ env.VERSION }}"! echo "Version being built against is version ${{ env.VERSION }}"!
- name: Create GitHub release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
tag_name: ${{ env.VERSION }}
release_name: ${{ env.VERSION }} Release
- name: Save release upload URL to artifact
run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url
- name: Save version number to artifact - name: Save version number to artifact
run: echo "${{ env.VERSION }}" > artifacts/release-version run: echo "${{ env.VERSION }}" > release-version
- name: Upload artifacts - name: Upload release-version as artifact
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v2
with: with:
name: artifacts retention-days: 3
path: artifacts name: release-version
path: release-version
build-release: build-release:
name: build-release name: build-release
needs: [create-github-release] needs: [initialize-release-job]
runs-on: ${{ matrix.triple.os }} runs-on: ${{ matrix.triple.os }}
container: ${{ matrix.triple.container }} container: ${{ matrix.triple.container }}
env: env:
@ -74,7 +59,6 @@ jobs:
os: "ubuntu-18.04", os: "ubuntu-18.04",
target: "x86_64-unknown-linux-gnu", target: "x86_64-unknown-linux-gnu",
cross: false, cross: false,
artifact: true,
strip: true, strip: true,
} }
- { - {
@ -95,7 +79,6 @@ jobs:
os: "ubuntu-18.04", os: "ubuntu-18.04",
target: "x86_64-unknown-linux-musl", target: "x86_64-unknown-linux-musl",
cross: false, cross: false,
artifact: true,
strip: true, strip: true,
} }
- { - {
@ -108,21 +91,14 @@ jobs:
os: "macOS-latest", os: "macOS-latest",
target: "x86_64-apple-darwin", target: "x86_64-apple-darwin",
cross: false, cross: false,
artifact: true,
strip: true, strip: true,
} }
- { - {
os: "windows-2019", os: "windows-2019",
target: "x86_64-pc-windows-msvc", target: "x86_64-pc-windows-msvc",
cross: false, cross: false,
artifact: true,
}
- {
os: "windows-2019",
target: "i686-pc-windows-msvc",
cross: false,
artifact: true,
} }
- { os: "windows-2019", target: "i686-pc-windows-msvc", cross: false }
- { - {
os: "windows-2019", os: "windows-2019",
target: "x86_64-pc-windows-gnu", target: "x86_64-pc-windows-gnu",
@ -134,7 +110,6 @@ jobs:
os: "ubuntu-18.04", os: "ubuntu-18.04",
target: "aarch64-unknown-linux-gnu", target: "aarch64-unknown-linux-gnu",
cross: true, cross: true,
artifact: true,
} }
# armv7 # armv7
@ -142,7 +117,6 @@ jobs:
os: "ubuntu-18.04", os: "ubuntu-18.04",
target: "armv7-unknown-linux-gnueabihf", target: "armv7-unknown-linux-gnueabihf",
cross: true, cross: true,
artifact: true,
} }
# PowerPC 64 LE # PowerPC 64 LE
@ -165,25 +139,6 @@ jobs:
with: with:
fetch-depth: 1 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 - name: Install toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -233,47 +188,29 @@ jobs:
tar -czvf bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz btm completion 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 echo "ASSET=bottom_${{ matrix.triple.target }}${{ matrix.triple.suffix }}.tar.gz" >> $GITHUB_ENV
- name: Upload main release - name: Create release directory for artifact, move file
uses: actions/upload-release-asset@v1.0.1 shell: bash
id: upload run: |
env: mkdir release
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} mv ${{ env.ASSET }} release/
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
- name: Add download asset to artifact if required
if: matrix.triple.artifact == true
run: cp ${{ env.ASSET }} artifacts/
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifacts
- name: Compress completion files (Linux x86-64 GNU) - name: Compress completion files (Linux x86-64 GNU)
if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == ''
shell: bash shell: bash
run: | run: |
tar -C ./completion -czvf completion.tar.gz . tar -C ./completion -czvf completion.tar.gz .
mv completion.tar.gz release/
- name: Release completion files (Linux x86-64 GNU) - name: Save release as artifact
if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' uses: actions/upload-artifact@v2
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }} retention-days: 3
asset_path: completion.tar.gz name: release
asset_name: completion.tar.gz path: release
asset_content_type: application/octet-stream
build-msi: build-msi:
name: build-msi name: build-msi
needs: [create-github-release] needs: [initialize-release-job]
runs-on: "windows-2019" runs-on: "windows-2019"
env: env:
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
@ -285,23 +222,20 @@ jobs:
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
- name: Get release download URL - name: Get release version
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
name: artifacts name: release-version
path: artifacts path: release-version
- name: Set release upload URL and release version - name: Set release version
shell: bash shell: bash
run: | run: |
release_upload_url="$(cat ./artifacts/release-upload-url)" release_version="$(cat ./release-version/release-version)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
release_version="$(cat ./artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables - name: Validate release version
run: | run: |
echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}"
echo "Release version: ${{ env.RELEASE_VERSION }}" echo "Release version: ${{ env.RELEASE_VERSION }}"
- name: Install Net-Framework-Core (Windows x86-64 MSVC) - name: Install Net-Framework-Core (Windows x86-64 MSVC)
@ -332,35 +266,29 @@ jobs:
cargo wix init cargo wix init
cargo wix cargo wix
- name: Upload msi file
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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
- name: Build winget - name: Build winget
run: | run: |
python "./deployment/packager.py" ${{ env.RELEASE_VERSION }} "./deployment/windows/winget/winget.yaml.template" "Clement.bottom.yaml" "SHA256" "./bottom_x86_64_installer.msi" python "./deployment/packager.py" ${{ env.RELEASE_VERSION }} "./deployment/windows/winget/winget.yaml.template" "Clement.bottom.yaml" "SHA256" "./bottom_x86_64_installer.msi"
$Code = powershell ./deployment/windows/winget/get_product_code.ps1 ./bottom_x86_64_installer.msi $Code = powershell ./deployment/windows/winget/get_product_code.ps1 ./bottom_x86_64_installer.msi
python "./deployment/windows/winget/product_code.py" Clement.bottom.yaml $Code python "./deployment/windows/winget/product_code.py" Clement.bottom.yaml $Code
- name: Upload winget file - name: Create release directory for artifact, move files
uses: actions/upload-release-asset@v1.0.1 shell: bash
env: run: |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} mkdir release
mv bottom_x86_64_installer.msi release/
mv Clement.bottom.yaml release/
- name: Save release as artifact
uses: actions/upload-artifact@v2
with: with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }} retention-days: 3
asset_path: Clement.bottom.yaml name: release
asset_name: Clement.bottom.yaml path: release
asset_content_type: application/octet-stream
build-deb: build-deb:
name: build-deb name: build-deb
needs: [create-github-release] needs: [initialize-release-job]
runs-on: "ubuntu-18.04" runs-on: "ubuntu-18.04"
env: env:
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
@ -370,23 +298,20 @@ jobs:
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Get release download URL - name: Get release version
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
name: artifacts name: release-version
path: artifacts path: release-version
- name: Set release upload URL and release version - name: Set release version
shell: bash shell: bash
run: | run: |
release_upload_url="$(cat ./artifacts/release-upload-url)" release_version="$(cat ./release-version/release-version)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
release_version="$(cat ./artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables - name: Validate release version
run: | run: |
echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}"
echo "Release version: ${{ env.RELEASE_VERSION }}" echo "Release version: ${{ env.RELEASE_VERSION }}"
- name: Install toolchain - name: Install toolchain
@ -407,19 +332,22 @@ jobs:
cargo deb cargo deb
cp ./target/debian/bottom_*.deb ./bottom_${{ env.RELEASE_VERSION }}_amd64.deb cp ./target/debian/bottom_*.deb ./bottom_${{ env.RELEASE_VERSION }}_amd64.deb
- name: Upload Debian file (Linux x86-64 GNU) - name: Create release directory for artifact, move file
uses: actions/upload-release-asset@v1.0.1 shell: bash
env: run: |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} mkdir release
with: mv bottom_${{ env.RELEASE_VERSION }}_amd64.deb release/
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
additional-file-generation: - name: Save release as artifact
uses: actions/upload-artifact@v2
with:
retention-days: 3
name: release
path: release
generate-choco:
needs: [build-release] needs: [build-release]
name: additional-file-generation name: generate-choco
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
@ -429,36 +357,96 @@ jobs:
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
- name: Get release download URL - name: Get release version
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
name: artifacts name: release-version
path: artifacts path: release-version
- name: Set release upload URL, download URL and version - name: Set release version
shell: bash shell: bash
run: | run: |
release_upload_url="$(cat ./artifacts/release-upload-url)" release_version="$(cat ./release-version/release-version)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
release_version="$(cat ./artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables - name: Validate release version
run: | run: |
echo "Release upload url: ${{ env.RELEASE_UPLOAD_URL }}"
echo "Release version: ${{ env.RELEASE_VERSION }}" echo "Release version: ${{ env.RELEASE_VERSION }}"
- name: Get release artifacts
uses: actions/download-artifact@v2
with:
name: release
path: release
- name: Execute choco packaging script - name: Execute choco packaging script
run: | 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/chocolatey_install.ps1.template" "bottom.nuspec" "tools/chocolatey_install.ps1" "tools/" python "./deployment/windows/choco/choco_packager.py" "./release/bottom_i686-pc-windows-msvc.zip" "./release/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" zip -r choco.zip "bottom.nuspec" "tools"
- name: Upload choco.zip to release - name: Move release file into release directory
uses: actions/upload-release-asset@v1.0.1 shell: bash
env: run: |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} mv choco.zip release/
- name: Save release as artifact
uses: actions/upload-artifact@v2
with: with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }} retention-days: 3
asset_path: choco.zip name: release
asset_name: choco.zip path: release
asset_content_type: application/octet-stream
upload-release:
name: upload-release
runs-on: ubuntu-latest
needs: [generate-choco, build-deb, build-msi]
steps:
- name: Get release version
uses: actions/download-artifact@v2
with:
name: release-version
path: release-version
- name: Set release version
shell: bash
run: |
release_version="$(cat ./release-version/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release version
run: |
echo "Release version: ${{ env.RELEASE_VERSION }}"
- 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: Upload all saved release files
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
tag_name: ${{ env.RELEASE_VERSION }}
draft: true
fail_on_unmatched_files: true
name: ${{ env.RELEASE_VERSION }} Release
body: |
<!-- Write summary here -->
---
## Features
## Changes
## Bug Fixes
## Internal Changes
files: |
./release/*

View File

@ -188,14 +188,14 @@ jobs:
shell: bash shell: bash
run: | run: |
mkdir release mkdir release
mv ${{ env.ASSET }} release mv ${{ env.ASSET }} release/
- name: Compress completion files (Linux x86-64 GNU) - name: Compress completion files (Linux x86-64 GNU)
if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == '' if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == ''
shell: bash shell: bash
run: | run: |
tar -C ./completion -czvf completion.tar.gz . tar -C ./completion -czvf completion.tar.gz .
mv completion.tar.gz release mv completion.tar.gz release/
- name: Save release files as artifacts - name: Save release files as artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
@ -216,7 +216,7 @@ jobs:
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Get release download URL - name: Get release version
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
name: release-version name: release-version
@ -228,7 +228,7 @@ jobs:
release_version="$(cat ./release-version/release-version)" release_version="$(cat ./release-version/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables - name: Validate release version
run: | run: |
echo "Release version: ${{ env.RELEASE_VERSION }}" echo "Release version: ${{ env.RELEASE_VERSION }}"
@ -264,7 +264,7 @@ jobs:
shell: bash shell: bash
run: | run: |
mkdir release mkdir release
mv bottom_x86_64_installer.msi release mv bottom_x86_64_installer.msi release/
- name: Save msi file as artifacts - name: Save msi file as artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
@ -285,19 +285,19 @@ jobs:
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Get release download URL - name: Get release version
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
name: release-version name: release-version
path: release-version path: release-version
- name: Set release upload URL and release version - name: Set release version
shell: bash shell: bash
run: | run: |
release_version="$(cat ./release-version/release-version)" release_version="$(cat ./release-version/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables - name: Validate release version
run: | run: |
echo "Release version: ${{ env.RELEASE_VERSION }}" echo "Release version: ${{ env.RELEASE_VERSION }}"
@ -323,7 +323,7 @@ jobs:
shell: bash shell: bash
run: | run: |
mkdir release mkdir release
mv bottom_${{ env.RELEASE_VERSION }}_amd64.deb release mv bottom_${{ env.RELEASE_VERSION }}_amd64.deb release/
- name: Save Debian file as artifacts - name: Save Debian file as artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2