release workflow optiomization #76
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: Release UDX Worker | |
on: | |
push: | |
# branches: | |
# - latest | |
jobs: | |
test-pipeline: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
outputs: | |
semVer: ${{ steps.gitversion.outputs.semVer }} | |
changelog: ${{ steps.changelog.outputs.changelog }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v2 | |
with: | |
versionSpec: "5.12.0" | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v2 | |
with: | |
useConfigFile: true | |
configFilePath: ci/git-version.yml | |
- name: Build Docker image and export cache | |
uses: docker/build-push-action@v6 | |
id: build-image | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
load: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
tags: | | |
usabilitydynamics/udx-worker:${{ steps.gitversion.outputs.semVer }} | |
usabilitydynamics/udx-worker:latest | |
build-args: | | |
GIT_VERSION=${{ steps.gitversion.outputs.semVer }} | |
- name: Generate changelog | |
id: changelog | |
run: | | |
git log $(git describe --tags --abbrev=0)..HEAD -- . --pretty=format:"- %s" > changelog.txt | |
CHANGELOG=$(cat changelog.txt | jq -sRr @uri) | |
echo "changelog<<EOF" >> $GITHUB_ENV | |
echo "$CHANGELOG" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
github-release: | |
runs-on: ubuntu-latest | |
needs: [test-pipeline] | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure git for pushing | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "UDX Worker" | |
- name: Create GitHub Tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git tag ${{ needs.test-pipeline.outputs.semVer }} | |
git push origin ${{ needs.test-pipeline.outputs.semVer }} | |
- name: Create GitHub release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ needs.test-pipeline.outputs.semVer }} | |
release_name: ${{ needs.test-pipeline.outputs.semVer }} | |
body: ${{ needs.test-pipeline.outputs.changelog }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
docker-release: | |
runs-on: ubuntu-latest | |
needs: [test-pipeline, github-release] | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Push Docker image (cached) | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
tags: | | |
usabilitydynamics/udx-worker:${{ needs.test-pipeline.outputs.semVer }} | |
usabilitydynamics/udx-worker:latest | |
- name: Log out from Docker Hub | |
run: docker logout |