Merge pull request #303 from kjsanger/chore/tidy-build #7
Workflow file for this run
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: "Create release" | |
on: | |
push: | |
tags: | |
- "*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l -e -o pipefail {0} | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: "Fetch Tags" | |
# Workaround for https://github.com/actions/checkout/issues/290 | |
run: | | |
# Avoid git exiting when Actions runs | |
git config --global --add safe.directory "$PWD" | |
git fetch --tags --force | |
- name: "Build source package" | |
uses: wtsi-npg/[email protected] | |
with: | |
build-image: | |
# The image choice is somewhat flexible because this is creating a source package. | |
# The choice below favours being close to the current production environment. | |
ghcr.io/wtsi-npg/ub-18.04-irods-clients-dev-4.2.11:latest | |
build-script: | |
./.github/workflows/build-release.sh | |
- name: "Upload source package" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: baton-release-tarball | |
path: "baton-*.tar.gz*" | |
release: | |
runs-on: ubuntu-latest | |
needs: "build" | |
defaults: | |
run: | |
shell: bash -l -e -o pipefail {0} | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: "Fetch Tags" | |
# Workaround for https://github.com/actions/checkout/issues/290 | |
run: | | |
# Avoid git exiting when Actions runs | |
git config --global --add safe.directory "$PWD" | |
git fetch --tags --force | |
- name: "Get release variables" | |
run: | | |
echo 'RELEASE_VERSION='$(git describe --always --tags) >> $GITHUB_ENV | |
echo 'MASTER_SHA='$(git rev-parse origin/master) >> $GITHUB_ENV | |
- name: "Download source package" | |
uses: actions/download-artifact@v4 | |
with: | |
name: baton-release-tarball | |
- name: "Create GitHub release" | |
uses: ncipollo/[email protected] | |
with: | |
name: ${{ env.RELEASE_VERSION }} | |
prerelease: ${{ !(github.sha == env.MASTER_SHA) }} | |
artifacts: "baton-*.tar.gz*" | |
removeArtifacts: true | |
artifactErrorsFailBuild: true | |
generateReleaseNotes: true | |
outputs: | |
isRelease: ${{ github.sha == env.MASTER_SHA }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [build, release] | |
# Workaround for https://github.com/actions/runner/issues/1483 | |
# Actions coerces boolean to string | |
if: needs.release.outputs.isRelease == 'true' | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: "Fetch Tags" | |
# Workaround for https://github.com/actions/checkout/issues/290 | |
run: | | |
# Avoid git exiting when Actions runs | |
git config --global --add safe.directory "$PWD" | |
git fetch --tags --force | |
- name: "Set up Docker Buildx" | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- name: "Login to Docker registry" | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Build and push Docker image" | |
run: | | |
cd release | |
make GITHUB_ACTIONS=${GITHUB_ACTIONS} GITHUB_REPOSITORY_OWNER=${{ github.repository_owner }} | |
docker image prune --force | |
docker images | |
make push GITHUB_ACTIONS=${GITHUB_ACTIONS} GITHUB_REPOSITORY_OWNER=${{ github.repository_owner }} |