add version numbers

This commit is contained in:
Ben Sarmiento
2023-10-29 06:53:27 +01:00
parent ea8085be0e
commit e33e725fb4

View File

@@ -16,11 +16,8 @@ jobs:
steps: steps:
- id: set_version - id: set_version
run: | run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then CURRENT_DATE=$(date +'%Y%m%d%H%M')
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT echo "version=beta-${CURRENT_DATE}" >> $GITHUB_OUTPUT
else
echo "version=latest" >> $GITHUB_OUTPUT
fi
build: build:
name: Build name: Build
@@ -62,7 +59,6 @@ jobs:
run: | run: |
zip zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }} zip zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}
# List files (for debugging)
- name: List files - name: List files
run: ls -alh run: ls -alh
@@ -82,42 +78,37 @@ jobs:
- name: Download all artifacts - name: Download all artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
- name: Install jq
run: sudo apt-get install jq
- name: Create Release in other repo - name: Create Release in other repo
id: create_release id: create_release
run: | run: |
# Generate the current date in the required format
CURRENT_DATE=$(date +'%Y%m%d%H%M')
# Create the release in the other repo
RESPONSE=$(curl -s -X POST \ RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${{ secrets.PAT }}" \ -H "Authorization: token ${{ secrets.PAT }}" \
-H "Accept: application/vnd.github.v3+json" \ -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/debridmediamanager/zurg-testing/releases \ https://api.github.com/repos/debridmediamanager/zurg-testing/releases \
-d '{ -d '{
"tag_name": "release-'$CURRENT_DATE'", "tag_name": "${{ needs.determine_version.outputs.build_version }}",
"name": "Release '$CURRENT_DATE'", "name": "${{ needs.determine_version.outputs.build_version }}",
"draft": false, "draft": false,
"prerelease": false "prerelease": false
}') }')
# Extract the release ID from the response
RELEASE_ID=$(echo "$RESPONSE" | jq ".id") RELEASE_ID=$(echo "$RESPONSE" | jq ".id")
# Set the RELEASE_ID environment variable for subsequent steps # Set the RELEASE_ID environment variable for subsequent steps
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
- name: List files
run: ls -alh
- name: Upload Artifacts to other repo's release - name: Upload Artifacts to other repo's release
run: | run: |
for artifact in $(ls); do for artifact in $(ls -1 *.zip); do
if [[ -f "$artifact" ]]; then if [[ -f "$artifact" ]]; then
curl -s -X POST \ curl -s -X POST \
-H "Authorization: token ${{ secrets.PAT }}" \ -H "Authorization: token ${{ secrets.PAT }}" \
-H "Accept: application/vnd.github.v3+json" \ -H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: $(file -b --mime-type $artifact)" \ -H "Content-Type: $(file -b --mime-type $artifact)" \
--data-binary "@$artifact" \ --data-binary "@$artifact" \
"https://uploads.github.com/repos/debridmediamanager/zurg-testing/releases/${RELEASE_ID}/assets?name=$(basename $artifact)" "https://uploads.github.com/repos/debridmediamanager/zurg-testing/releases/${{ steps.create_release.outputs.release_id }}/assets?name=$(basename $artifact)"
fi fi
done done