Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#50: Add tags to CI output #69

Merged
merged 3 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}"