Skip to content

Commit

Permalink
Merge pull request #69 from ferrous-systems/tag-ci-output
Browse files Browse the repository at this point in the history
#50: Add tags to CI output
  • Loading branch information
jonathanpallant authored Jul 13, 2023
2 parents 82d020e + f6b7470 commit 0e58d8b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:

jobs:
deploy:
build:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -17,6 +17,12 @@ jobs:
with:
tool: mdslides@0.3,mdbook@0.4,mdbook-mermaid@0.12

- name: Find slug name
run: |
slug=$(./describe.sh "${GITHUB_REF}")
echo "Building with slug '${slug}'"
echo "slug=${slug}" >> "${GITHUB_ENV}"
- name: Build book-and-slides
run: |
./training-slides/build.sh
Expand All @@ -27,10 +33,12 @@ jobs:
- name: Assemble Artifacts
run: |
mkdir -p ./output
mv ./training-slides/slides ./output/training-slides-presentation
mv ./training-slides/book ./output/training-slides-book
zip -r ./output.zip ./output
echo "Making ./rust-training-${{ env.slug }}..."
mkdir -p ./rust-training-${{ env.slug }}
mv ./training-slides/slides ./rust-training-${{ env.slug }}/training-slides-presentation
mv ./training-slides/book ./rust-training-${{ env.slug }}/training-slides-book
echo "Compressing ./rust-training-${{ env.slug }}.zip..."
zip -r ./rust-training-${{ env.slug }}.zip ./rust-training-${{ env.slug }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
Expand All @@ -39,11 +47,11 @@ jobs:
name: Artifacts
if-no-files-found: error
path: |
./output
./rust-training-*/
- name: Create and Upload Release
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
id: create_release
uses: ncipollo/release-action@v1
with:
artifacts: ./output.zip
artifacts: ./rust-training-${{ env.slug }}.zip
19 changes: 19 additions & 0 deletions describe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -euo pipefail

GIVEN_REF=$1

case "${GIVEN_REF}" in
refs/heads/*)
slug="$(git branch --show)-$(git rev-parse --short HEAD)"
;;
refs/tags/*)
slug="$(echo "${GIVEN_REF}" | awk '{split($0,a,"/"); print a[3]}')"
;;
refs/pull/*/merge)
slug="pr-$(echo "${GIVEN_REF}" | awk '{split($0,a,"/"); print a[3]}')-$(git rev-parse --short HEAD)"
;;
esac

echo "${slug}"

0 comments on commit 0e58d8b

Please sign in to comment.