Update publish-release.yml

This commit is contained in:
Adel Salakh 2025-05-14 22:28:25 +02:00 committed by GitHub
parent a395660e67
commit 19e70ffc69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 87 additions and 104 deletions

View File

@ -1,20 +1,19 @@
name: Publish Release
run-name: ${{ github.event.pull_request.head.ref }}
run-name: Release ${{ github.event.inputs.version }}
on:
pull_request_target:
branches:
- master
types:
- closed
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. v1.2.3)'
required: true
type: string
permissions:
contents: write
pull-requests: write
jobs:
publish:
if: github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.version }}
@ -22,48 +21,43 @@ jobs:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
fetch-depth: 0
fetch-tags: true
- name: Tag release
id: tag
run: |
# Set up github-actions[bot] user
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
# Get the version from the branch name
branch="${{ github.event.pull_request.head.ref }}"
version="${branch#release/}"
echo ${version}
# Use version from input
version="${{ github.event.inputs.version }}"
echo "Tagging release $version"
# Tag and create release
git tag -a "${version}" -m "Release ${version}"
echo "version=${version}" >> $GITHUB_OUTPUT
id: tag
# Create annotated tag
git tag -a "$version" -m "Release $version"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Set up go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Get dependencies
env:
# renovate: datasource=github-tags depName=golangci/golangci-lint
GOLANGCI_LINT_VERSION: v1.64.8
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
# Install go dependencies
go mod download
- name: Build Artifacts
run: make release
# Upload artifacts in case of workflow failure
- name: Upload Artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: oauth2-proxy-artifacts
@ -71,35 +65,26 @@ jobs:
release/*.tar.gz
release/*.txt
- name: Create release
- name: Push tag
run: git push origin "${{ steps.tag.outputs.version }}"
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get version from tag
version=$(git describe --tags --abbrev=0)
# Extract CHANGELOG
version=${{ steps.tag.outputs.version }}
numericVersion="${version#v}"
notes=$(sed -E "/^# (v|V)$numericVersion$/,/^# (v|V)/!d;//d" CHANGELOG.md)
# Publish release tag
git push origin "${version}"
# Create github release
gh release create "${version}" \
--title "${version}" \
--notes "${notes}" \
--prerelease
# Upload artifacts
gh release upload "${version}" release/*.tar.gz
gh release upload "${version}" release/*.txt
notes=$(sed -n "/^# ${numericVersion}$/,/^# /{ /# ${numericVersion}$/d; /# /!p }" CHANGELOG.md)
gh release create "$version" \
--title "$version" \
--notes "$notes" \
--prerelease \
&& gh release upload "$version" release/*.tar.gz release/*.txt
docker:
needs: publish
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
@ -127,9 +112,7 @@ jobs:
mask-password: 'true'
- name: Build images
run: |
make build-docker-all
run: make build-docker-all
- name: Push images
run: |
make push-docker-all
run: make push-docker-all