@@ -0,0 +1,126 @@
1+name: Publish Release
2+run-name: ${{ github.event.pull_request.head.ref }}
3+
4+on:
5+ pull_request_target:
6+ branches:
7+ - master
8+ types:
9+ - closed
10+
11+permissions:
12+ contents: write
13+ pull-requests: write
14+
15+jobs:
16+ publish:
17+ if: github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')
18+ runs-on: ubuntu-latest
19+ outputs:
20+ tag: ${{ steps.tag.outputs.version }}
21+ steps:
22+ - name: Check out code
23+ uses: actions/checkout@v3
24+ with:
25+ ref: ${{ github.event.pull_request.merge_commit_sha }}
26+ fetch-depth: 0
27+ fetch-tags: true
28+
29+ - name: Tag release
30+ run: |
31+ # Set up github-actions[bot] user
32+ git config --local user.name "github-actions[bot]"
33+ git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
34+
35+ # Get the version from the branch name
36+ branch="${{ github.event.pull_request.head.ref }}"
37+ version="${branch#release/}"
38+ echo ${version}
39+
40+ # Tag and create release
41+ git tag -a "${version}" -m "Release ${version}"
42+ echo "version=${version}" >> $GITHUB_OUTPUT
43+ id: tag
44+
45+ - name: Set up go
46+ uses: actions/setup-go@v2
47+ with:
48+ go-version: 1.19
49+
50+ - name: Get dependencies
51+ run: |
52+ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
53+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
54+ chmod +x ./cc-test-reporter
55+
56+ # Install go depedencies
57+ go mod download
58+
59+ - name: Build Artifacts
60+ run: make release
61+
62+ # Upload artifacts in case of workflow failure
63+ - name: Upload Artifacts
64+ uses: actions/upload-artifact@v3
65+ with:
66+ name: oauth2-proxy-artifacts
67+ path: |
68+ release/*.tar.gz
69+ release/*.txt
70+
71+ - name: Create release
72+ env:
73+ GH_TOKEN: ${{ github.token }}
74+ run: |
75+ # Get version from tag
76+ version=$(git describe --tags --abbrev=0)
77+
78+ # Extract CHANGELOG
79+ numericVersion="${version#v}"
80+ notes=$(sed -E "/^# (v|V)$numericVersion$/,/^# (v|V)/!d;//d" CHANGELOG.md)
81+
82+ # Publish release tag
83+ git push origin "${version}"
84+
85+ # Create github release
86+ gh release create "${version}" \
87+ --title "${version}" \
88+ --notes "${notes}" \
89+ --prerelease
90+
91+ # Upload artifacts
92+ gh release upload "${version}" release/*.tar.gz
93+ gh release upload "${version}" release/*.txt
94+
95+ docker:
96+ needs: publish
97+ runs-on: ubuntu-latest
98+ steps:
99+ - name: Check out code
100+ uses: actions/checkout@v3
101+ with:
102+ ref: ${{ needs.publish.outputs.tag }}
103+ fetch-depth: 0
104+ fetch-tags: true
105+
106+ - name: Set up QEMU
107+ uses: docker/setup-qemu-action@v2
108+
109+ - name: Set up Docker Buildx
110+ id: buildx
111+ uses: docker/setup-buildx-action@v2
112+
113+ - name: Login to quay.io
114+ uses: docker/login-action@v2
115+ with:
116+ registry: quay.io/oauth2-proxy
117+ username: ${{ secrets.REGISTRY_USERNAME }}
118+ password: ${{ secrets.REGISTRY_PASSWORD }}
119+
120+ - name: Build images
121+ run: |
122+ make docker-all
123+
124+ - name: Push images
125+ run: |
126+ make docker-push-all