Skip to content

add a directory when creating tar archive #46

add a directory when creating tar archive

add a directory when creating tar archive #46

Workflow file for this run

# .github/workflows/release.yaml
name: new release
on:
push:
tags:
- "*" # triggers only if push new tag version, like `0.8.4` or else
env:
PROJECT: aprilsh
BIN_DIR: bin
permissions:
contents: write
pull-requests: write
jobs:
change_build_info:
strategy:
fail-fast: false
runs-on: ubuntu-latest
outputs:
commit_hash: ${{ steps.commit-and-push.outputs.commit_hash }}
tar_version: ${{ steps.change.outputs.tar_version }}
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- name: checkout
uses: actions/checkout@v4
# with:
# ref: ${{ github.head_ref }}
# - name: Set up Go
# uses: actions/setup-go@master
# with:
# go-version: 1.21
- name: change build info
id: change
shell: bash
run: |
git config --global --add safe.directory /__w/aprilsh/aprilsh
sed -i -e "s/pkgver=.*/pkgver=`git describe --tags --abbrev=0`/g" ./build/APKBUILD
sed -i -e "s/.*_GitVersion=.*/_GitVersion=`git describe --tags`/g" ./build/APKBUILD
sed -i -e "s/.*_GitCommit=.*/_GitCommit=`git rev-parse HEAD`/g" ./build/APKBUILD
sed -i -e "s/.*_GitBranch=.*/_GitBranch=`git rev-parse --abbrev-ref HEAD`/g" ./build/APKBUILD
echo "tar_version=$(git describe --tags)" >> $GITHUB_OUTPUT
- name: commit and push changes
id: commit-and-push
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
# - name: commit files
# run: |
# git config --local user.name "github-actions[bot]"
# git config --local user.email "github-actions[bot]@users.noreply.github.com"
# if ! git diff --exit-code; then
# git add build/APKBUILD
# git commit -m "GH Action update files"
# fi
#
# - name: push changes
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# force: true
#
# - name: output value
# id: commit-and-push
# run: |
# echo "commit_hash=$(git rev-parse HEAD)"
# echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
release:
needs: change_build_info
runs-on: ubuntu-latest
steps:
- name: checkout repo again
uses: actions/checkout@master
with:
ref: ${{ needs.change_build_info.outputs.commit_hash }}
- name: print value
id: print
run: |
echo "github.ref=${{ github.ref }}"
echo "github.sha=${{ github.sha }}"
echo "commit_hash=${{ needs.change_build_info.outputs.commit_hash }}"
head -n 22 build/APKBUILD
- name: generate tar ball
id: vars
shell: bash
run: |
tar cvzf ${{ env.PROJECT }}-${{ needs.change_build_info.outputs.tar_version }}.tar.gz \
--transform 's,^,${{ env.PROJECT }}-${{ needs.change_build_info.outputs.tar_version }}/,' \
LICENSE \
README.md \
build \
data \
doc \
encrypt \
frontend \
go.mod \
go.sum \
img \
network \
protobufs \
statesync \
terminal \
util
- name: publish release assets
uses: softprops/action-gh-release@master
with:
generate_release_notes: true
target_commitish: ${{ needs.change_build_info.outputs.commit_hash }}
files: |
${{ env.PROJECT }}-*.tar.gz