Better feedback for git sync and backup #123
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: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
- main | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
unit_test: | |
name: Unit test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
with: | |
submodules: "true" | |
- run: npm install -g bats | |
- name: Install Bats | |
run: bats -v | |
- name: Run unit tests | |
run: bats ./test | |
deb_package: | |
name: Build debian package (artifact) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: sudo apt install --yes --no-install-recommends lintian dpkg gzip | |
- name: Print dependecies info | |
run: | | |
dpkg-deb --version | |
gzip --version | |
lintian --version | |
- name: Build deb archive | |
run: bash ci/make_deb_archive.sh | |
- name: Lint deb archive | |
run: lintian --fail-on warning --no-tag-display-limit release/*.deb | |
- name: Upload deb package artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: deb-package | |
path: release/*.deb | |
if-no-files-found: error | |
retention-days: 5 | |
version_check: | |
runs-on: ubuntu-latest | |
outputs: | |
latest_tag: ${{ steps.check.outputs.latest_tag }} | |
source_version: ${{ steps.check.outputs.source_version }} | |
is_release: ${{ steps.check.outputs.is_release }} | |
steps: | |
- name: Checkout repository code | |
uses: actions/checkout@v3 | |
- name: Fetch tags | |
# I've noticed sometimes checkout doesnt fetch tags | |
run: git fetch --tags | |
- name: Check Versions | |
id: check | |
run: | | |
v=( $(bash ci/get_versions.sh) ) | |
echo "latest_tag=${v[0]} source_version=${v[1]} is_release=${v[2]}" | |
echo "latest_tag=${v[0]}" >> "$GITHUB_OUTPUT" | |
echo "source_version=${v[1]}" >> "$GITHUB_OUTPUT" | |
echo "is_release=${v[2]}" >> "$GITHUB_OUTPUT" | |
# Released source archive has a different sha 256 from git archive | |
# Thus I cant pre-computed, and must generate homebrew formula post release | |
#homebrew_formula: | |
# runs-on: ubuntu-latest | |
# needs: [version_check] | |
# if: success() | |
# env: | |
# VERSION: ${{needs.version_check.outputs.source_version}} | |
# steps: | |
# - name: Check out repository code | |
# uses: actions/checkout@v3 | |
# - name: Create Homebrew formula | |
# run: | | |
# SHA256=$(git archive --format=tar.gz -v -6 HEAD | sha256sum | cut -d ' ' -f 1) | |
# echo "$SHA256" | |
# FORMULA_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${VERSION}.tar.gz" | |
# bash ci/make_formula.sh "$FORMULA_URL" "$SHA256" "$VERSION" | |
# - name: Upload Homebrew formula artifact | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: homebrew-formula | |
# path: release/*.rb | |
# if-no-files-found: error | |
# retention-days: 5 | |
release: | |
runs-on: ubuntu-latest | |
needs: [version_check, deb_package, unit_test] | |
if: success() && github.ref_name == 'main' && needs.version_check.outputs.is_release == 'true' | |
env: | |
VERSION: ${{needs.version_check.outputs.source_version}} | |
GH_TOKEN: ${{ secrets.JOURNALSCRIPT_WORKFLOW_TRIGGER_PAT }} | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: release/ | |
- name: Create Release Log | |
run: bash ci/extract_latest_release.sh CHANGELOG.md > release/RELEASE_LOG.md | |
- name: Display structure of downloaded files | |
run: | | |
ls -R ${{ github.workspace }} | |
cat release/RELEASE_LOG.md | |
- name: Release | |
id: release | |
run: | | |
gh release create ${VERSION} \ | |
--notes-file release/RELEASE_LOG.md \ | |
--title "Journalscript ${VERSION}" \ | |
release/deb-package/*.deb |