Skip to content

Commit 5ea3c25

Browse files
committed
resync build.yml
1 parent 55efc94 commit 5ea3c25

File tree

1 file changed

+47
-78
lines changed

1 file changed

+47
-78
lines changed

.github/workflows/build.yml

Lines changed: 47 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ jobs:
2626
arch: x86_64
2727

2828
steps:
29+
- name: Security Intention
30+
run: |
31+
echo "This workflow is intended to build the project in a secure manner:"
32+
echo " - Only installs absolutely essential and trusted dependencies. (steps \"Install *\")"
33+
echo " - Uses HTTPS for direct package downloads"
34+
echo " - Only uses official Github Actions \"actions/*\""
35+
2936
- name: Checkout code
3037
uses: actions/checkout@v4
3138

@@ -152,85 +159,47 @@ jobs:
152159
name: sqlrsync-${{ matrix.os }}-${{ matrix.arch }}
153160
path: release/*
154161

155-
auto-tag:
156-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
157-
runs-on: ubuntu-latest
158-
outputs:
159-
version: ${{ steps.extract-version.outputs.version }}
160-
tag-created: ${{ steps.tag-check.outputs.tag-created }}
161-
steps:
162-
- name: Checkout code
163-
uses: actions/checkout@v4
164-
with:
165-
fetch-depth: 0
166-
167-
- name: Extract version from main.go
168-
id: extract-version
169-
run: |
170-
VERSION=$(grep 'var VERSION = ' client/main.go | sed 's/var VERSION = "\(.*\)"/\1/')
171-
echo "version=$VERSION" >> $GITHUB_OUTPUT
172-
echo "Extracted version: $VERSION"
173-
174-
- name: Check if tag exists
175-
id: tag-check
176-
run: |
177-
VERSION=${{ steps.extract-version.outputs.version }}
178-
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
179-
echo "Tag v$VERSION already exists"
180-
echo "tag-created=false" >> $GITHUB_OUTPUT
181-
else
182-
echo "Tag v$VERSION does not exist, will create"
183-
echo "tag-created=true" >> $GITHUB_OUTPUT
184-
fi
185-
186-
- name: Create and push tag
187-
if: steps.tag-check.outputs.tag-created == 'true'
188-
run: |
189-
VERSION=${{ steps.extract-version.outputs.version }}
190-
git config user.name "github-actions[bot]"
191-
git config user.email "github-actions[bot]@users.noreply.github.com"
192-
git tag -a "v$VERSION" -m "Release v$VERSION"
193-
git push origin "v$VERSION"
194-
env:
195-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196-
197-
create-release:
198-
if: needs.auto-tag.outputs.tag-created == 'true'
199-
needs: [build, auto-tag]
200-
runs-on: ubuntu-latest
201-
steps:
202-
- name: Download all artifacts
203-
uses: actions/download-artifact@v4
204-
205-
- name: Create GitHub Release
206-
uses: softprops/action-gh-release@v1
207-
with:
208-
tag_name: v${{ needs.auto-tag.outputs.version }}
209-
name: Release v${{ needs.auto-tag.outputs.version }}
210-
draft: false
211-
prerelease: false
212-
files: |
213-
sqlrsync-linux-x86_64/sqlrsync-linux-x86_64
214-
sqlrsync-darwin-amd64/sqlrsync-darwin-amd64
215-
sqlrsync-darwin-arm64/sqlrsync-darwin-arm64
216-
generate_release_notes: true
217-
env:
218-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
219-
220162
release:
221-
if: github.event_name == 'release'
163+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
222164
needs: build
165+
permissions:
166+
contents: write
167+
packages: write
168+
issues: write
169+
pull-requests: write
170+
actions: write
223171
runs-on: ubuntu-latest
224172
steps:
225-
- name: Download all artifacts
226-
uses: actions/download-artifact@v4
227-
228-
- name: Upload to release
229-
uses: softprops/action-gh-release@v1
230-
with:
231-
files: |
232-
sqlrsync-linux-x86_64/sqlrsync-linux-x86_64
233-
sqlrsync-darwin-amd64/sqlrsync-darwin-amd64
234-
sqlrsync-darwin-arm64/sqlrsync-darwin-arm64
235-
env:
236-
GITHUB_TOKEN: ${{ secrets.AUTH_TOKEN_GITHUB }}
173+
- uses: actions/checkout@v5
174+
175+
- name: Extract version from main.go
176+
id: extract-version
177+
run: |
178+
VERSION=$(grep 'var VERSION = ' client/main.go | sed 's/var VERSION = "\(.*\)"/\1/')
179+
echo "version=$VERSION" >> $GITHUB_OUTPUT
180+
echo "Extracted version: $VERSION"
181+
182+
- name: Check if tag exists
183+
id: tag-check
184+
run: |
185+
VERSION=${{ steps.extract-version.outputs.version }}
186+
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
187+
echo "Tag v$VERSION already exists"
188+
echo "tag-created=false" >> $GITHUB_OUTPUT
189+
else
190+
echo "Tag v$VERSION does not exist, will create"
191+
echo "tag-created=true" >> $GITHUB_OUTPUT
192+
193+
- name: Download all release artifacts
194+
if: steps.tag-check.outputs.tag-created == 'true'
195+
uses: actions/download-artifact@v5
196+
197+
- name: Create tag and GitHub Release, attach artifact
198+
run: |
199+
TAG=v${{ steps.extract-version.outputs.version }}
200+
git config user.name "${{ github.actor }}"
201+
git config user.email "${{ github.actor }}@users.noreply.github.com"
202+
git tag -a $TAG -m "Release $TAG"
203+
git push origin $TAG
204+
# create the release and attach the artifact (gh CLI)
205+
gh release create $TAG --generate-notes release/*

0 commit comments

Comments
 (0)