Nightly Release #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Nightly Release | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
jobs: | |
release: | |
name: Create Nightly Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: devel | |
- name: Set APP_VERSION with Date | |
id: version | |
run: | | |
DATE=$(date +%Y%m%d) | |
VERSION="unstable-${DATE}" | |
echo "APP_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Build Go Application | |
run: | | |
APP_VERSION=${{ env.APP_VERSION }} | |
CGO_ENABLED=0 GOOS=linux go build -ldflags "-X 'main.AppVersion=$APP_VERSION'" -o packagelock-${APP_VERSION} | |
- name: Create Release Archive | |
run: | | |
mkdir -p release | |
mv packagelock-${{ env.APP_VERSION }} release/ | |
tar -czvf release/packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz -C release packagelock-${{ env.APP_VERSION }} | |
- name: Calculate Checksum | |
run: | | |
md5sum release/packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz | cut -f1 -d' ' > release/packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz.md5 | |
- name: Create Nightly Release if it doesn't exist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if ! gh release view nightly > /dev/null 2>&1; then | |
gh release create nightly -t "Nightly Release" -n "Automated Nightly Build" | |
fi | |
- name: Upload Assets to Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload nightly \ | |
release/packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz \ | |
release/packagelock-${{ env.APP_VERSION }}-linux-amd64-nightly.tar.gz.md5 \ | |
--clobber |