Update publish-release.yml
This commit is contained in:
parent
a395660e67
commit
19e70ffc69
|
|
@ -1,135 +1,118 @@
|
||||||
name: Publish Release
|
name: Publish Release
|
||||||
run-name: ${{ github.event.pull_request.head.ref }}
|
run-name: Release ${{ github.event.inputs.version }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request_target:
|
workflow_dispatch:
|
||||||
branches:
|
inputs:
|
||||||
- master
|
version:
|
||||||
types:
|
description: 'Release version (e.g. v1.2.3)'
|
||||||
- closed
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
if: github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
tag: ${{ steps.tag.outputs.version }}
|
tag: ${{ steps.tag.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.merge_commit_sha }}
|
fetch-depth: 0
|
||||||
fetch-depth: 0
|
fetch-tags: true
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- name: Tag release
|
- name: Tag release
|
||||||
run: |
|
id: tag
|
||||||
# Set up github-actions[bot] user
|
run: |
|
||||||
git config --local user.name "github-actions[bot]"
|
# Set up github-actions[bot] user
|
||||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
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
|
# Use version from input
|
||||||
branch="${{ github.event.pull_request.head.ref }}"
|
version="${{ github.event.inputs.version }}"
|
||||||
version="${branch#release/}"
|
echo "Tagging release $version"
|
||||||
echo ${version}
|
|
||||||
|
|
||||||
# Tag and create release
|
# Create annotated tag
|
||||||
git tag -a "${version}" -m "Release ${version}"
|
git tag -a "$version" -m "Release $version"
|
||||||
echo "version=${version}" >> $GITHUB_OUTPUT
|
echo "version=$version" >> $GITHUB_OUTPUT
|
||||||
id: tag
|
|
||||||
|
|
||||||
- name: Set up go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version-file: go.mod
|
|
||||||
|
|
||||||
- name: Get dependencies
|
- name: Set up Go
|
||||||
env:
|
uses: actions/setup-go@v5
|
||||||
# renovate: datasource=github-tags depName=golangci/golangci-lint
|
with:
|
||||||
GOLANGCI_LINT_VERSION: v1.64.8
|
go-version-file: go.mod
|
||||||
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
|
- name: Get dependencies
|
||||||
go mod download
|
env:
|
||||||
|
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
|
||||||
|
go mod download
|
||||||
|
|
||||||
- name: Build Artifacts
|
- name: Build Artifacts
|
||||||
run: make release
|
run: make release
|
||||||
|
|
||||||
# Upload artifacts in case of workflow failure
|
|
||||||
- name: Upload Artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: oauth2-proxy-artifacts
|
|
||||||
path: |
|
|
||||||
release/*.tar.gz
|
|
||||||
release/*.txt
|
|
||||||
|
|
||||||
- name: Create release
|
- name: Upload Artifacts
|
||||||
env:
|
if: failure()
|
||||||
GH_TOKEN: ${{ github.token }}
|
uses: actions/upload-artifact@v4
|
||||||
run: |
|
with:
|
||||||
# Get version from tag
|
name: oauth2-proxy-artifacts
|
||||||
version=$(git describe --tags --abbrev=0)
|
path: |
|
||||||
|
release/*.tar.gz
|
||||||
|
release/*.txt
|
||||||
|
|
||||||
# Extract CHANGELOG
|
- name: Push tag
|
||||||
numericVersion="${version#v}"
|
run: git push origin "${{ steps.tag.outputs.version }}"
|
||||||
notes=$(sed -E "/^# (v|V)$numericVersion$/,/^# (v|V)/!d;//d" CHANGELOG.md)
|
|
||||||
|
|
||||||
# Publish release tag
|
- name: Create GitHub release
|
||||||
git push origin "${version}"
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
version=${{ steps.tag.outputs.version }}
|
||||||
|
numericVersion="${version#v}"
|
||||||
|
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
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
needs: publish
|
needs: publish
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ needs.publish.outputs.tag }}
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
- name: Check out code
|
- name: Configure AWS credentials
|
||||||
uses: actions/checkout@v4
|
uses: aws-actions/configure-aws-credentials@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ needs.publish.outputs.tag }}
|
role-to-assume: ${{ vars.AWS_ECR_ROLE }}
|
||||||
fetch-depth: 0
|
aws-region: ${{ vars.AWS_REGION }}
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- name: Configure AWS credentials
|
- name: Set up QEMU
|
||||||
uses: aws-actions/configure-aws-credentials@v4
|
uses: docker/setup-qemu-action@v3
|
||||||
with:
|
|
||||||
role-to-assume: ${{ vars.AWS_ECR_ROLE }}
|
|
||||||
aws-region: ${{ vars.AWS_REGION }}
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-qemu-action@v3
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Set up Docker Buildx
|
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Login to ECR
|
|
||||||
id: ecr_login
|
|
||||||
uses: aws-actions/amazon-ecr-login@v1
|
|
||||||
with:
|
|
||||||
mask-password: 'true'
|
|
||||||
|
|
||||||
- name: Build images
|
- name: Login to ECR
|
||||||
run: |
|
id: ecr_login
|
||||||
make build-docker-all
|
uses: aws-actions/amazon-ecr-login@v1
|
||||||
|
with:
|
||||||
- name: Push images
|
mask-password: 'true'
|
||||||
run: |
|
|
||||||
make push-docker-all
|
- name: Build images
|
||||||
|
run: make build-docker-all
|
||||||
|
|
||||||
|
- name: Push images
|
||||||
|
run: make push-docker-all
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue