Update release.yaml - pull commits and fetch changes; list recent tag… #2
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 | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
REGISTRY: quay.io | |
PASSWORD_KEY: QUAY_TOKEN | |
USERNAME: ${{ vars.QUAY_USERNAME }} | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: '.nvmrc' | |
cache: 'yarn' | |
- name: Install Dependencies | |
run: | | |
yarn install --frozen-lockfile | |
- name: Create Release Pull Request | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
version: yarn run version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get Latest Tag and Publish | |
if: steps.changesets.outputs.hasChangesets == 'false' | |
run: | | |
# pull recent commits and tags | |
git pull origin; git fetch --all | |
echo "recent tags:"; git rev-list --tags --max-count=4 | |
latest_tag="$(git describe --tags $(git rev-list --tags --max-count=1))"; echo "Got latest tag = $latest_tag" | |
echo "latest_tag=$latst_tag" >> "$GITHUB_ENV" | |
git push origin "$latest_tag" || exit 1 # fail if tag already exists | |
- name: Publish Image | |
if: steps.changesets.outputs.hasChangesets == 'false' | |
uses: ./.github/actions/docker-build | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ env.USERNAME }} | |
password: ${{ secrets[env.PASSWORD_KEY] }} | |
imageName: ${{ env.IMAGE_NAME }} | |
imageTags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
push: true | |