Skip to content

Commit dc00d7d

Browse files
committed
Tag and release v2
1 parent 98a7dda commit dc00d7d

File tree

1 file changed

+47
-79
lines changed

1 file changed

+47
-79
lines changed

.github/workflows/build.yml

Lines changed: 47 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111
jobs:
1212
build:
1313
name: Build for ${{ matrix.os }}
14-
runs-on: ${{ matrix.runs-on }}
1514
strategy:
1615
matrix:
1716
include:
@@ -26,6 +25,13 @@ jobs:
2625
arch: x86_64
2726

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

@@ -152,85 +158,47 @@ jobs:
152158
name: sqlrsync-${{ matrix.os }}-${{ matrix.arch }}
153159
path: release/*
154160

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-
220161
release:
221-
if: github.event_name == 'release'
162+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
222163
needs: build
164+
permissions:
165+
contents: write
166+
packages: write
167+
issues: write
168+
pull-requests: write
169+
actions: write
223170
runs-on: ubuntu-latest
224171
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 }}
172+
- uses: actions/checkout@v5
173+
174+
- name: Extract version from main.go
175+
id: extract-version
176+
run: |
177+
VERSION=$(grep 'var VERSION = ' client/main.go | sed 's/var VERSION = "\(.*\)"/\1/')
178+
echo "version=$VERSION" >> $GITHUB_OUTPUT
179+
echo "Extracted version: $VERSION"
180+
181+
- name: Check if tag exists
182+
id: tag-check
183+
run: |
184+
VERSION=${{ steps.extract-version.outputs.version }}
185+
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
186+
echo "Tag v$VERSION already exists"
187+
echo "tag-created=false" >> $GITHUB_OUTPUT
188+
else
189+
echo "Tag v$VERSION does not exist, will create"
190+
echo "tag-created=true" >> $GITHUB_OUTPUT
191+
192+
- name: Download all release artifacts
193+
if: steps.tag-check.outputs.tag-created == 'true'
194+
uses: actions/download-artifact@v5
195+
196+
- name: Create tag and GitHub Release, attach artifact
197+
run: |
198+
TAG=v${{ steps.extract-version.outputs.version }}
199+
git config user.name "${{ github.actor }}"
200+
git config user.email "${{ github.actor }}@users.noreply.github.com"
201+
git tag -a $TAG -m "Release $TAG"
202+
git push origin $TAG
203+
# create the release and attach the artifact (gh CLI)
204+
gh release create $TAG --generate-notes release/*

0 commit comments

Comments
 (0)